/* -*- c -*- ****************************************************************
 *
 *               Copyright 2003 Samsung Electronics (UK) Ltd.
 *               Copyright 2005,2007 SpongeLava Ltd.
 * 
 *
 *  System        : mhegenc
 *  Module        : mhegenc
 *
 *  Object Name   : $RCSfile$
 *  Revision      : $Revision: 5 $
 *  Date          : $Date: 2009-09-01 15:40:02 +0000 (Tue, 01 Sep 2009) $
 *  Author        : $Author: imedland@dtg.org.uk $
 *  Created By    : Paul Thomas
 *  Create Date   : Mon Jun 9 2003
 *
 *  Description 
 *               print routines for mhegenc ASN.1 -> text.
 *  Notes
 *
 *  History
 *
 *   0.9   Oct 2007 Added SetDesktopColour and OrigDesktopColour for
 *                  freesat extensions.
 *         Aug 2009 Added GetCounterPosition and GetCounterMaxPosition for
 *                  DBook 6.1
 *      
 ****************************************************************************
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 ****************************************************************************/
/* Note from author. Some parts of this file were generated by snacc 1.3.
   (mainly prototypes) see notice in mh_snacc.c
*/
#include "asn-incl.h"
#include "mh_snacc.h"

static const char *rcsid=
"@(#) $Id: mh_print.c 5 2009-09-01 15:40:02Z imedland@dtg.org.uk $";

int include_comments = 0;

/*****************************************************************************/
/* Enum Printers                                                             */
/*****************************************************************************/

const char *m_arrEventTypeId[] =
{
    "IsAvailable",
    "ContentAvailable",
    "IsDeleted",
    "IsRunning",
    "IsStopped",
    "UserInput",
    "AnchorFired",
    "TimerFired",
    "AsynchStopped",
    "InteractionCompleted",
    "TokenMovedFrom",
    "TokenMovedTo",
    "StreamEvent",
    "StreamPlaying",
    "StreamStopped",
    "CounterTrigger",
    "HighlightOn",
    "HighlightOff",
    "CursorEnter",
    "CursorLeave",
    "IsSelected",
    "IsDeselected",
    "TestEvent",
    "FirstItemPresented",
    "LastItemPresented",
    "HeadItems",
    "TailItems",
    "ItemSelected",
    "ItemDeselected",
    "EntryFieldFull",
    "EngineEvent",
    "FocusMoved",
    "SliderValueChanged"
};

const char *m_arrJustificationId[] =
{
    "start",
    "end",
    "centre",
    "justified"
};

const char *m_arrLineOrientationId[] =
{
    "vertical",
    "horizontal"
};
const char *m_arrStartCornerId[] =
{
    "upper-left",
    "upper-right",
    "lower-left",
    "lower-right"
};
const char *m_arrStorageId[] =
{
    "memory",
    "stream"
};
const char *m_arrTerminationId[] =
{
    "freeze",
    "disappear"
};
const char *m_arrOrientationId[] =
{
    "left",
    "right",
    "up",
    "down"
};
const char *m_arrSliderStyleId[] =
{
    "normal",
    "thermometer",
    "proportional"
};
const char *m_arrInputTypeId[] =
{
    "alpha",
    "numeric",
    "any",
    "listed"
};
const char *m_arrButtonStyleId[] =
{
    "pushbutton",
    "radiobutton",
    "checkbox"
};

static void
PrintJustification(FILE *f, Justification v)
{
    if( v < 1 || v > JUSTIFIED )
        fprintf(f, "INVALID ");
    else
        fprintf(f, "%s ", m_arrJustificationId[v-1]);
}
static void
PrintLineOrientation(FILE *f, LineOrientation v)
{
    if( v < 1 || v > HORIZONTAL )
        fprintf(f, "INVALID ");
    else
        fprintf(f, "%s ", m_arrLineOrientationId[v-1]);
}
static void
PrintStartCorner(FILE *f, StartCorner v)
{
    if( v < 1 || v > LOWER_RIGHT )
        fprintf(f, "INVALID ");
    else
        fprintf(f, "%s ", m_arrStartCornerId[v-1]);
}
static void
PrintStorage(FILE *f, Storage v)
{
    if( v < 1 || v > STREAM )
        fprintf(f, "INVALID ");
    else
        fprintf(f, "%s ", m_arrStorageId[v-1]);
}
static void
PrintTermination(FILE *f, Termination v)
{
    if( v < 1 || v > DISAPPEAR )
        fprintf(f, "INVALID ");
    else
        fprintf(f, "%s ", m_arrTerminationId[v-1]);
}
static void
PrintOrientation(FILE *f, Orientation v)
{
    if( v < 1 || v > DOWN )
        fprintf(f, "INVALID ");
    else
        fprintf(f, "%s ", m_arrOrientationId[v-1]);
}
static void
PrintSliderStyle(FILE *f, SliderStyle v)
{
    if( v < 1 || v > PROPORTIONAL )
        fprintf(f, "INVALID ");
    else
        fprintf(f, "%s ", m_arrSliderStyleId[v-1]);
}
static void
PrintInputType(FILE *f, InputType v)
{
    if( v < 1 || v > LISTED )
        fprintf(f, "INVALID ");
    else
        fprintf(f, "%s ", m_arrInputTypeId[v-1]);
}
static void
PrintButtonStyle(FILE *f, ButtonStyle v)
{
    if( v < 1 || v > CHECKBOX )
        fprintf(f, "INVALID ");
    else
        fprintf(f, "%s ", m_arrButtonStyleId[v-1]);
}
static void
PrintEventType(FILE* f, EventType v)
{
    if( v < 1 || v > SLIDER_VALUE_CHANGED )
        fprintf(f, "INVALID ");
    else
        fprintf(f, "%s ", m_arrEventTypeId[v-1]);
}

static int _PrintAsnInt(FILE *f, AsnInt *v, unsigned short int indent)
{
    return fprintf (f,"%d", *v);
}

static int
PrintQPrintableOctetString PARAMS ((f, v),
                                   FILE* f _AND_
                                   AsnOcts *v)
{
    //TODO:
    int ii, chars = 0;
    fputc('\'', f);
    chars++;
    for( ii = 0; ii < v->octetLen; ii++ ){
        if( ( (v->octs[ii] >= 32)
              && (v->octs[ii] <= 126)
              && (v->octs[ii] != 61)
              && (v->octs[ii] != 39)
              )
            || (v->octs[ii] == 9))
        {
            fputc(v->octs[ii], f);
            chars++;
        }
        else
        {
            int nibble;
            fputc('=', f);
            nibble = ((unsigned char)v->octs[ii] & 0xF0) >> 4;
            if( nibble < 10 )
                fputc(nibble + '0', f);
            else
                fputc(nibble + 'A' - 10, f);
            nibble = (unsigned char)v->octs[ii] & 0x0F;
            if( nibble < 10 )
                fputc(nibble + '0', f);
            else
                fputc(nibble + 'A' - 10, f);
            chars += 3;
        }
    }
    fputc('\'', f);
    fputc(' ', f);
    chars += 2;
    return chars;
}
static int
PrintQPrintableBinaryOctetString PARAMS ((f, v),
                                         FILE* f _AND_
                                         AsnOcts *v)
{
    //TODO:
    int ii, chars = 0;
    fputc('\'', f);
    chars++;
    for( ii = 0; ii < v->octetLen; ii++ ){
        int nibble;
        fputc('=', f);
        nibble = ((unsigned char)v->octs[ii] & 0xF0) >> 4;
        if( nibble < 10 )
            fputc(nibble + '0', f);
        else
            fputc(nibble + 'A' - 10, f);
        nibble = (unsigned char)v->octs[ii] & 0x0F;
        if( nibble < 10 )
            fputc(nibble + '0', f);
        else
            fputc(nibble + 'A' - 10, f);
        chars+=3;
    }
    fputc('\'', f);
    fputc(' ', f);
    chars+=2;
    return chars;
}

static int
PrintObjectReference PARAMS ((f, v),
                             FILE* f _AND_
                             ObjectReference *v)
{
    int chars = 0;
    switch (v->choiceId)
    {
    case OBJECTREFERENCE_EXTERNAL_REFERENCE:
        chars += fprintf (f,"( ");
        chars += PrintQPrintableOctetString(f, &v->a.external_reference->group_identifier);
        chars += _PrintAsnInt (f, (&v->a.external_reference->object_number), 0);
        chars += fprintf (f," ) ");
        break;
        
    case OBJECTREFERENCE_INTERNAL_REFERENCE:
        chars += _PrintAsnInt (f, (&v->a.internal_reference), 0);
        chars += fprintf(f, " ");
        break;
        
    }
    return chars;
}  /* PrintObjectReference */

#define PrintIndirectReference PrintObjectReference

static int
PrintGenericObjectReference PARAMS ((f, v, indent),
                                    FILE* f _AND_
                                    GenericObjectReference *v _AND_
                                    unsigned short int indent)
{
    int chars = 0;
    switch (v->choiceId)
    {
    case GENERICOBJECTREFERENCE_DIRECT_REFERENCE:
        chars += PrintObjectReference (f, (v->a.direct_reference));
        break;

    case GENERICOBJECTREFERENCE_INDIRECT_REFERENCE:
        chars += fprintf(f, ":IndirectRef ");
        chars += PrintIndirectReference (f, (v->a.indirect_reference));
        break;

    }
    return chars;
}  /* PrintGenericObjectReference */

static void
PrintGenericContentReference PARAMS ((f, v, indent),
                                     FILE* f _AND_
                                     GenericContentReference *v _AND_
                                     unsigned short int indent)
{
    switch (v->choiceId)
    {
    case GENERICCONTENTREFERENCE_CONTENT_REFERENCE:
        PrintQPrintableOctetString (f, (v->a.content_reference));
        break;

    case GENERICCONTENTREFERENCE_INDIRECT_REFERENCE:
        fprintf(f, ":IndirectRef ");
        PrintIndirectReference (f, (v->a.indirect_reference));
        break;

    }
}  /* PrintGenericContentReference */

static int
PrintGenericInteger PARAMS ((f, v, indent),
                            FILE* f _AND_
                            GenericInteger *v _AND_
                            unsigned short int indent)
{
    int chars = 0;
    switch (v->choiceId)
    {
    case GENERICINTEGER_INTEGER:
        chars += _PrintAsnInt (f, (&v->a.integer), 0);
        chars += fprintf (f," ");
        break;

    case GENERICINTEGER_INDIRECT_REFERENCE:
        chars += fprintf(f, ":IndirectRef ");
        chars += PrintIndirectReference (f, (v->a.indirect_reference));
        break;

    }
    return chars;
}  /* PrintGenericInteger */

static void
PrintGenericBoolean PARAMS ((f, v, indent),
                            FILE* f _AND_
                            GenericBoolean *v _AND_
                            unsigned short int indent)
{
    switch (v->choiceId)
    {
    case GENERICBOOLEAN_BOOLEAN:
        PrintAsnBool (f, (&v->a.boolean), 0);
        fprintf(f, " ");
        break;

    case GENERICBOOLEAN_INDIRECT_REFERENCE:
        fprintf(f, ":IndirectRef ");
        PrintIndirectReference (f, (v->a.indirect_reference));
        break;

    }
}  /* PrintGenericBoolean */

static void
PrintGenericOctetString PARAMS ((f, v, indent),
                                FILE* f _AND_
                                GenericOctetString *v _AND_
                                unsigned short int indent)
{
    switch (v->choiceId)
    {
    case GENERICOCTETSTRING_OCTETSTRING:
        PrintQPrintableOctetString (f, (v->a.octetstring));
        break;

    case GENERICOCTETSTRING_INDIRECT_REFERENCE:
        fprintf (f,":IndirectRef ");
        PrintIndirectReference (f, (v->a.indirect_reference));
        break;

    }
}  /* PrintGenericOctetString */

static void
PrintParameter PARAMS ((f, v, indent),
FILE* f _AND_
Parameter *v _AND_
unsigned short int indent)
{
    switch (v->choiceId)
    {
    case PARAMETER_NEW_GENERIC_BOOLEAN:
        fprintf (f,":GBoolean ");
        PrintGenericBoolean (f, (v->a.new_generic_boolean), 0);
        break;
        
    case PARAMETER_NEW_GENERIC_INTEGER:
        fprintf (f,":GInteger ");
        PrintGenericInteger (f, (v->a.new_generic_integer), 0);
        break;
        
    case PARAMETER_NEW_GENERIC_OCTETSTRING:
        fprintf (f,":GOctetString ");
        PrintGenericOctetString (f, (v->a.new_generic_octetstring), 0);
        break;
        
    case PARAMETER_NEW_GENERIC_OBJECT_REFERENCE:
        fprintf (f,":GObjectRef ");
        PrintGenericObjectReference(f, (v->a.new_generic_object_reference), 0);
        break;
        
    case PARAMETER_NEW_GENERIC_CONTENT_REFERENCE:
        fprintf (f,":GContentRef ");
        PrintGenericContentReference(
            f, (v->a.new_generic_content_reference), 0);
        break;

    }
}  /* PrintParameter */



static void
PrintNewContentSize PARAMS ((f, v, indent),
FILE* f _AND_
NewContentSize *v _AND_
unsigned short int indent)
{
    switch (v->choiceId)
    {
      case NEWCONTENTSIZE_CONTENT_SIZE:
          fprintf (f,":NewContentSize ");
          PrintGenericInteger (f, (v->a.content_size), 0);
          break;

      case NEWCONTENTSIZE_NULL:
          break;

    }
}  /* PrintNewContentSize */


static void
PrintNewReferencedContent PARAMS ((f, v, indent),
FILE* f _AND_
NewReferencedContent *v _AND_
unsigned short int indent)
{
    if (v == NULL)
        return;

    fprintf (f,"( ");

    PrintGenericContentReference (f, (v->generic_content_reference), 0);
    PrintNewContentSize (f, (v->new_content_size), 0);
    if (NOT_NULL ((v->new_content_cache_priority)))
    {
    fprintf (f,":NewCCPriority ");
    PrintGenericInteger (f, (v->new_content_cache_priority), 0);
    }
    fprintf (f,") ");
    
}  /* PrintNewReferencedContent */

static void
PrintNewContent PARAMS ((f, v, indent),
FILE* f _AND_
NewContent *v _AND_
unsigned short int indent)
{
    switch (v->choiceId)
    {
      case NEWCONTENT_NEW_INCLUDED_CONTENT:
          PrintGenericOctetString (f, (v->a.new_included_content), 0);
          break;

      case NEWCONTENT_NEW_REFERENCED_CONTENT:
          fprintf (f,":NewRefContent ");
          PrintNewReferencedContent (f, (v->a.new_referenced_content), indent + stdIndentG);
          break;

    }
}  /* PrintNewContent */

static void
PrintConnectionTagOrNull PARAMS ((f, v, indent),
FILE* f _AND_
ConnectionTagOrNull *v _AND_
unsigned short int indent)
{
    switch (v->choiceId)
    {
      case CONNECTIONTAGORNULL_CONNECTION_TAG:
          fprintf(f, ":ConnectionTag ");
          PrintGenericInteger (f, (v->a.connection_tag), indent);
          break;

      case CONNECTIONTAGORNULL_NULL:
          break;

    }
}  /* PrintConnectionTagOrNull */

static void
PrintElementaryAction PARAMS ((f, v, indent),
                              FILE* f _AND_
                              ElementaryAction *v _AND_
                              unsigned short int indent)
{
    Indent(f, indent);
    switch (v->choiceId)
    {
    case ELEMENTARYACTION_ACTIVATE:
        fprintf(f, ":Activate ( ");
        PrintGenericObjectReference (f, (v->a.activate), 0);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_ADD:
        fprintf(f, ":Add ( ");
        PrintGenericObjectReference (f, (v->a.add->target), 0);
        PrintGenericInteger (f, (v->a.add->value), 0);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_ADD_ITEM:
        fprintf(f, ":AddItem ( ");
        PrintGenericObjectReference (f, (v->a.add_item->target), 0);
        PrintGenericInteger (f, (v->a.add_item->item_index), 0);
        PrintGenericObjectReference (f, (v->a.add_item->visible_reference), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_APPEND:
        fprintf(f, ":Append ( ");
        PrintGenericObjectReference (f, (v->a.append->target), 0);
        PrintGenericOctetString(f, (v->a.append->append_value), 0);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_BRING_TO_FRONT:
        fprintf(f, ":BringToFront ( ");
        PrintGenericObjectReference (f, (v->a.bring_to_front), 0);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_CALL:
        fprintf(f, ":Call ( ");
        PrintGenericObjectReference (f, (v->a.call->target), 0);
        PrintObjectReference (f, (v->a.call->call_succeeded));
        fprintf(f, "\n");
        {
            Parameter *tmp;
            FOR_EACH_LIST_ELMT (tmp,  v->a.call->parameters){
                Indent(f, indent + 8);
                PrintParameter(f, tmp, 0);
                fprintf(f, "\n");
            }
        }
        Indent(f, indent);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_CALL_ACTION_SLOT:
        fprintf(f, ":CallActionSlot ( ");
        PrintGenericObjectReference (f, (v->a.call_action_slot->target), 0);
        PrintGenericInteger (f, (v->a.call_action_slot->index), 0);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_CLEAR:
        fprintf(f, ":Clear ( ");
        PrintGenericObjectReference (f, (v->a.clear), 0);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_CLONE:
        fprintf(f, ":Clone ( ");
        PrintGenericObjectReference (f, (v->a.clone->target), 0);
        PrintObjectReference (f, (v->a.clone->clone_ref_var));
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_CLOSE_CONNECTION:
        fprintf(f, ":CloseConnection ( ");
        PrintGenericObjectReference (f, (v->a.close_connection->target), 0);
        PrintGenericInteger (f, (v->a.close_connection->connection_tag), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_DEACTIVATE:
        fprintf(f, ":Deactivate ( ");
        PrintGenericObjectReference (f, (v->a.deactivate), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_DEL_ITEM:
        fprintf(f, ":DelItem ( ");
        PrintGenericObjectReference (f, (v->a.del_item->target), 0);
        PrintGenericObjectReference (f, (v->a.del_item->visible_reference), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_DESELECT:
        fprintf(f, ":Deselect ( ");
        PrintGenericObjectReference (f, (v->a.deselect), 0);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_DESELECT_ITEM:
        fprintf(f, ":DeselectItem ( ");
        PrintGenericObjectReference (f, (v->a.deselect_item->target), 0);
        PrintGenericInteger (f, (v->a.deselect_item->item_index), 0);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_DIVIDE:
        fprintf(f, ":Divide ( ");
        PrintGenericObjectReference (f, (v->a.divide->target), 0);
        PrintGenericInteger (f, (v->a.divide->value), 0);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_DRAW_ARC:
        fprintf(f, ":DrawArc ( ");
        PrintGenericObjectReference (f, (v->a.draw_arc->target), 0);
        PrintGenericInteger (f, (v->a.draw_arc->x), 0);
        PrintGenericInteger (f, (v->a.draw_arc->y), 0);
        PrintGenericInteger (f, (v->a.draw_arc->ellipse_width), 0);
        PrintGenericInteger (f, (v->a.draw_arc->ellipse_height), 0);
        PrintGenericInteger (f, (v->a.draw_arc->start_angle), 0);
        PrintGenericInteger (f, (v->a.draw_arc->arc_angle), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_DRAW_LINE:
        fprintf(f, ":DrawLine ( ");
        PrintGenericObjectReference (f, (v->a.draw_line->target), 0);
        PrintGenericInteger (f, (v->a.draw_line->x1), 0);
        PrintGenericInteger (f, (v->a.draw_line->y1), 0);
        PrintGenericInteger (f, (v->a.draw_line->x2), 0);
        PrintGenericInteger (f, (v->a.draw_line->y2), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_DRAW_OVAL:
        fprintf(f, ":DrawOval ( ");
        PrintGenericObjectReference (f, (v->a.draw_oval->target), 0);
        PrintGenericInteger (f, (v->a.draw_oval->x), 0);
        PrintGenericInteger (f, (v->a.draw_oval->y), 0);
        PrintGenericInteger (f, (v->a.draw_oval->ellipse_width), 0);
        PrintGenericInteger (f, (v->a.draw_oval->ellipse_height), 0);
        fprintf(f, ") ");
        break;
        
#define WRAP_COLUMN 65
    case ELEMENTARYACTION_DRAW_POLYGON:
    {
        int col, list_indent;
        Point *tmp;
        list_indent = indent + fprintf(f, ":DrawPolygon ( ");
        col = list_indent;
        col += PrintGenericObjectReference (f, (v->a.draw_polygon->target), 0);
        col += fprintf(f, "( ");
        if( col < WRAP_COLUMN )
            list_indent = col;
        
        FOR_EACH_LIST_ELMT (tmp, v->a.draw_polygon->pointlist){
            if( col >= WRAP_COLUMN ){
                fputc('\n', f);
                col = list_indent;
                Indent(f, list_indent);
            }
            col += fprintf(f, "( ");
            col += PrintGenericInteger(f, tmp->x, 0);
            col += PrintGenericInteger(f, tmp->y, 0);
            col += fprintf(f, ") ");
        }
        fprintf(f, ") ) ");
        break;
    }
    case ELEMENTARYACTION_DRAW_POLYLINE:
    {
        int col, list_indent;
        Point *tmp;
        list_indent = indent + fprintf(f, ":DrawPolyline ( ");
        col = list_indent;
        col += PrintGenericObjectReference (f, (v->a.draw_polygon->target), 0);
        col += fprintf(f, "( ");
        if( col < WRAP_COLUMN )
            list_indent = col;
        
        FOR_EACH_LIST_ELMT (tmp, v->a.draw_polygon->pointlist){
            if( col >= WRAP_COLUMN ){
                fputc('\n', f);
                col = list_indent;
                Indent(f, list_indent);
            }
            col += fprintf(f, "( ");
            col += PrintGenericInteger(f, tmp->x, 0);
            col += PrintGenericInteger(f, tmp->y, 0);
            col += fprintf(f, ") ");
        }
        fprintf(f, ") ) ");
        break;
    }
    case ELEMENTARYACTION_DRAW_RECTANGLE:
        fprintf(f, ":DrawRectangle ( ");
        PrintGenericObjectReference (f, (v->a.draw_rectangle->target), 0);
        PrintGenericInteger (f, (v->a.draw_rectangle->x1), 0);
        PrintGenericInteger (f, (v->a.draw_rectangle->y1), 0);
        PrintGenericInteger (f, (v->a.draw_rectangle->x2), 0);
        PrintGenericInteger (f, (v->a.draw_rectangle->y2), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_DRAW_SECTOR:
        fprintf(f, ":DrawSector ( ");
        PrintGenericObjectReference (f, (v->a.draw_sector->target), 0);
        PrintGenericInteger (f, (v->a.draw_sector->x), 0);
        PrintGenericInteger (f, (v->a.draw_sector->y), 0);
        PrintGenericInteger (f, (v->a.draw_sector->ellipse_width), 0);
        PrintGenericInteger (f, (v->a.draw_sector->ellipse_height), 0);
        PrintGenericInteger (f, (v->a.draw_sector->start_angle), 0);
        PrintGenericInteger (f, (v->a.draw_sector->arc_angle), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_FORK:
        fprintf(f, ":Fork ( ");
        PrintGenericObjectReference (f, (v->a.fork->target), 0);
        PrintObjectReference (f, (v->a.fork->fork_succeeded));
        fprintf(f, "\n");
        {
            Parameter *tmp;
            FOR_EACH_LIST_ELMT (tmp,  v->a.fork->parameters){
                Indent(f, indent + 8);
                PrintParameter(f, tmp, 0);
                fprintf(f, "\n");
            }
        }
        Indent(f, indent);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_GET_AVAILABILITY_STATUS:
        fprintf(f, ":GetAvailabilityStatus ( ");
        PrintGenericObjectReference(
            f, v->a.get_availability_status->target, 0);
        PrintObjectReference(
            f, v->a.get_availability_status->availability_status_var);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_GET_BOX_SIZE:
        fprintf(f, ":GetBoxSize ( ");
        PrintGenericObjectReference(
            f, v->a.get_box_size->target, 0);
        PrintObjectReference(
            f, v->a.get_box_size->x_box_size_var);
        PrintObjectReference(
            f, v->a.get_box_size->y_box_size_var);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_GET_CELL_ITEM:
        fprintf(f, ":GetCellItem ( ");
        PrintGenericObjectReference(f, v->a.get_cell_item->target, 0);
        PrintGenericInteger (f, v->a.get_cell_item->cell_index, 0);
        PrintObjectReference(f, v->a.get_cell_item->item_ref_var);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_GET_CURSOR_POSITION:
        fprintf(f, ":GetCursorPosition ( ");
        PrintGenericObjectReference(f, v->a.get_cursor_position->target, 0);
        PrintObjectReference(f, v->a.get_cursor_position->x_out);
        PrintObjectReference(f, v->a.get_cursor_position->y_out);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_GET_ENGINE_SUPPORT:
        fprintf(f, ":GetEngineSupport ( ");
        PrintGenericObjectReference(f, v->a.get_engine_support->target, 0);
        PrintGenericOctetString(f, v->a.get_engine_support->feature, 0);
        PrintObjectReference(f, v->a.get_engine_support->answer);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_ENTRY_POINT:
        fprintf(f, ":GetEntryPoint ( ");
        PrintGenericObjectReference(f, v->a.get_entry_point->target, 0);
        PrintObjectReference(f, v->a.get_entry_point->entry_point_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_FILL_COLOUR:
        fprintf(f, ":GetFillColour ( ");
        PrintGenericObjectReference(f, v->a.get_fill_colour->target, 0);
        PrintObjectReference(f, v->a.get_fill_colour->fill_colour_var);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_GET_FIRST_ITEM:
        fprintf(f, ":GetFirstItem ( ");
        PrintGenericObjectReference(f, v->a.get_first_item->target, 0);
        PrintObjectReference(f, v->a.get_first_item->first_item_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_HIGHLIGHT_STATUS:
        fprintf(f, ":GetHighlightStatus ( ");
        PrintGenericObjectReference(f, v->a.get_highlight_status->target, 0);
        PrintObjectReference(
            f, v->a.get_highlight_status->highlight_status_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_INTERACTION_STATUS:
        fprintf(f, ":GetInteractionStatus ( ");
        PrintGenericObjectReference(f, v->a.get_interaction_status->target, 0);
        PrintObjectReference(
            f, v->a.get_interaction_status->interaction_status_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_ITEM_STATUS:
        fprintf(f, ":GetItemStatus ( ");
        PrintGenericObjectReference(f, v->a.get_item_status->target, 0);
        PrintGenericInteger(f, v->a.get_item_status->item_index, 0);
        PrintObjectReference(
            f, v->a.get_item_status->item_status_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_LABEL:
        fprintf(f, ":GetLabel ( ");
        PrintGenericObjectReference(f, v->a.get_label->target, 0);
        PrintObjectReference(
            f, v->a.get_label->label_var);        
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_LAST_ANCHOR_FIRED:
        fprintf(f, ":GetLastAnchorFired ( ");
        PrintGenericObjectReference(f, v->a.get_last_anchor_fired->target, 0);
        PrintObjectReference(
            f, v->a.get_last_anchor_fired->last_anchor_fired_var);        
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_LINE_COLOUR:
        fprintf(f, ":GetLineColour ( ");
        PrintGenericObjectReference(f, v->a.get_line_colour->target, 0);
        PrintObjectReference(
            f, v->a.get_line_colour->line_colour_var);        
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_LINE_STYLE:
        fprintf(f, ":GetLineStyle ( ");
        PrintGenericObjectReference(f, v->a.get_line_style->target, 0);
        PrintObjectReference(
            f, v->a.get_line_style->line_style_var);        
         fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_LINE_WIDTH:
        fprintf(f, ":GetLineWidth ( ");
        PrintGenericObjectReference(f, v->a.get_line_width->target, 0);
        PrintObjectReference(
            f, v->a.get_line_width->line_width_var);        
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_LIST_ITEM:
        fprintf(f, ":GetListItem ( ");
        PrintGenericObjectReference(f, v->a.get_list_item->target, 0);
        PrintGenericInteger(f, v->a.get_list_item->item_index, 0);
        PrintObjectReference(f, v->a.get_list_item->item_ref_var);        
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_LIST_SIZE:
        fprintf(f, ":GetListSize ( ");
        PrintGenericObjectReference(f, v->a.get_list_size->target, 0);
        PrintObjectReference(f, v->a.get_list_size->size_var);        
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_OVERWRITE_MODE:
        fprintf(f, ":GetOverwriteMode ( ");
        PrintGenericObjectReference(f, v->a.get_overwrite_mode->target, 0);
        PrintObjectReference(f, v->a.get_overwrite_mode->overwrite_mode_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_PORTION:
        fprintf(f, ":GetPortion ( ");
        PrintGenericObjectReference(f, v->a.get_portion->target, 0);
        PrintObjectReference(f, v->a.get_portion->portion_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_POSITION:
        fprintf(f, ":GetPosition ( ");
        PrintGenericObjectReference(f, v->a.get_position->target, 0);
        PrintObjectReference(f, v->a.get_position->x_position_var);
        PrintObjectReference(f, v->a.get_position->y_position_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_RUNNING_STATUS:
        fprintf(f, ":GetRunningStatus ( ");
        PrintGenericObjectReference(f, v->a.get_running_status->target, 0);
        PrintObjectReference(f, v->a.get_running_status->running_status_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_SELECTION_STATUS:
        fprintf(f, ":GetSelectionStatus ( ");
        PrintGenericObjectReference(f, v->a.get_selection_status->target, 0);
        PrintObjectReference(
            f, v->a.get_selection_status->selection_status_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_SLIDER_VALUE:
        fprintf(f, ":GetSliderValue ( ");
        PrintGenericObjectReference(f, v->a.get_slider_value->target, 0);
        PrintObjectReference(f, v->a.get_slider_value->slider_value_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_TEXT_CONTENT:
        fprintf(f, ":GetTextContent ( ");
        PrintGenericObjectReference(f, v->a.get_text_content->target, 0);
        PrintObjectReference(f, v->a.get_text_content->text_content_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_TEXT_DATA:
        fprintf(f, ":GetTextData ( ");
        PrintGenericObjectReference(f, v->a.get_text_data->target, 0);
        PrintObjectReference(f, v->a.get_text_data->text_data_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_TOKEN_POSITION:
        fprintf(f, ":GetTokenPosition ( ");
        PrintGenericObjectReference(f, v->a.get_token_position->target, 0);
        PrintObjectReference(f, v->a.get_token_position->token_position_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_VOLUME:
        fprintf(f, ":GetVolume ( ");
        PrintGenericObjectReference(f, v->a.get_volume->target, 0);
        PrintObjectReference(f, v->a.get_volume->volume_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_LAUNCH:
        fprintf(f, ":Launch ( ");
        PrintGenericObjectReference (f, (v->a.launch), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_LOCK_SCREEN:
        fprintf(f, ":LockScreen ( ");
        PrintGenericObjectReference (f, (v->a.lock_screen), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_MODULO:
        fprintf(f, ":Modulo ( ");
        PrintGenericObjectReference(f, v->a.modulo->target, 0);
        PrintGenericInteger(f, v->a.modulo->value, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_MOVE:
        fprintf(f, ":Move ( ");
        PrintGenericObjectReference(f, v->a.move->target, 0);
        PrintGenericInteger(f, v->a.move->movement_identifier, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_MOVE_TO:
        fprintf(f, ":MoveTo ( ");
        PrintGenericObjectReference(f, v->a.move_to->target, 0);
        PrintGenericInteger(f, v->a.move_to->index, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_MULTIPLY:
        fprintf(f, ":Multiply ( ");
        PrintGenericObjectReference(f, v->a.multiply->target, 0);
        PrintGenericInteger(f, v->a.multiply->value, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_OPEN_CONNECTION:
        fprintf(f, ":OpenConnection ( ");
        PrintGenericObjectReference(f, v->a.open_connection->target, 0);
        PrintObjectReference(f, v->a.open_connection->open_succeeded);
        PrintGenericOctetString(f, v->a.open_connection->protocol, 0);
        PrintGenericOctetString(f, v->a.open_connection->address, 0);
        PrintGenericInteger(f, v->a.open_connection->connection_tag, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_PRELOAD:
        fprintf(f, ":Preload ( ");
        PrintGenericObjectReference (f, (v->a.preload), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_PUT_BEFORE:
        fprintf(f, ":PutBefore ( ");
        PrintGenericObjectReference(f, v->a.put_before->target, 0);
        PrintGenericObjectReference(f, v->a.put_before->reference_visible, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_PUT_BEHIND:
        fprintf(f, ":PutBehind ( ");
        PrintGenericObjectReference(f, v->a.put_behind->target, 0);
        PrintGenericObjectReference(f, v->a.put_behind->reference_visible, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_QUIT:
        fprintf(f, ":Quit ( ");
        PrintGenericObjectReference (f, (v->a.quit), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_READ_PERSISTENT:
    {
        ObjectReference *tmp;
        fprintf(f, ":ReadPersistent ( ");
        PrintGenericObjectReference(f, v->a.read_persistent->target, 0);
        PrintObjectReference(f, v->a.read_persistent->read_succeeded);
        fprintf(f, "( ");
        FOR_EACH_LIST_ELMT (tmp,v->a.read_persistent->out_variables){
            PrintObjectReference(f, tmp);
        }
        fprintf(f, ") ");
        PrintGenericOctetString(f, v->a.read_persistent->in_file_name, 0);
        fprintf(f, ") ");
        break;
    }
    case ELEMENTARYACTION_RUN:
        fprintf(f, ":Run ( ");
        PrintGenericObjectReference (f, (v->a.run), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SCALE_BITMAP:
        fprintf(f, ":ScaleBitmap ( ");
        PrintGenericObjectReference(f, v->a.scale_bitmap->target, 0);
        PrintGenericInteger(f, v->a.scale_bitmap->x_scale, 0);
        PrintGenericInteger(f, v->a.scale_bitmap->y_scale, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SCALE_VIDEO:
        fprintf(f, ":ScaleVideo ( ");
        PrintGenericObjectReference(f, v->a.scale_video->target, 0);
        PrintGenericInteger(f, v->a.scale_video->x_scale, 0);
        PrintGenericInteger(f, v->a.scale_video->y_scale, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SCROLL_ITEMS:
        fprintf(f, ":ScrollItems ( ");
        PrintGenericObjectReference(f, v->a.scroll_items->target, 0);
        PrintGenericInteger(f, v->a.scroll_items->items_to_scroll, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SELECT:
        fprintf(f, ":Select ( ");
        PrintGenericObjectReference (f, (v->a.select), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SELECT_ITEM:
        fprintf(f, ":SelectItem ( ");
        PrintGenericObjectReference(f, v->a.select_item->target, 0);
        PrintGenericInteger(f, v->a.select_item->item_index, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SEND_EVENT:
        fprintf(f, ":SendEvent ( ");
        PrintGenericObjectReference(f, v->a.send_event->target, 0);
        PrintGenericObjectReference(
            f, v->a.send_event->emulated_event_source, 0);
        PrintEventType(f, v->a.send_event->emulated_event_type);
        if( v->a.send_event->emulated_event_data )
        {
            EmulatedEventData *data;
            data = v->a.send_event->emulated_event_data;
            switch(data->choiceId)
            {
            case EMULATEDEVENTDATA_NEW_GENERIC_BOOLEAN:
                fprintf(f, ":GBoolean ");
                PrintGenericBoolean(f, data->a.new_generic_boolean, 0);
                break;
            case EMULATEDEVENTDATA_NEW_GENERIC_INTEGER:
                fprintf(f, ":GInteger ");
                PrintGenericInteger(f, data->a.new_generic_integer, 0);
                break;
            case EMULATEDEVENTDATA_NEW_GENERIC_OCTET_STRING:
                fprintf(f, ":GOctetString ");
                PrintGenericOctetString(
                    f, data->a.new_generic_octet_string, 0);
                break;

            }
        }
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SEND_TO_BACK:
        fprintf(f, ":SendToBack ( ");
        PrintGenericObjectReference (f, (v->a.send_to_back), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_BOX_SIZE:
        fprintf(f, ":SetBoxSize ( ");
        PrintGenericObjectReference(f, v->a.set_box_size->target, 0);
        PrintGenericInteger(f, v->a.set_box_size->x_new_box_size, 0);
        PrintGenericInteger(f, v->a.set_box_size->y_new_box_size, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_CACHE_PRIORITY:
        fprintf(f, ":SetCachePriority ( ");
        PrintGenericObjectReference(f, v->a.set_cache_priority->target, 0);
        PrintGenericInteger(f, v->a.set_cache_priority->new_cache_priority, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_COUNTER_END_POSITION:
        fprintf(f, ":SetCounterEndPosition ( ");
        PrintGenericObjectReference(
            f, v->a.set_counter_end_position->target, 0);
        PrintGenericInteger(
            f, v->a.set_counter_end_position->new_counter_end_position, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_COUNTER_POSITION:
        fprintf(f, ":SetCounterPosition ( ");
        PrintGenericObjectReference(f, v->a.set_counter_position->target, 0);
        PrintGenericInteger(
            f, v->a.set_counter_position->new_counter_position, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_COUNTER_TRIGGER:
        fprintf(f, ":SetCounterTrigger ( ");
        PrintGenericObjectReference(f, v->a.set_counter_trigger->target, 0);
        PrintGenericInteger(
            f, v->a.set_counter_trigger->trigger_identifier, 0);
        PrintGenericInteger(
            f, v->a.set_counter_trigger->new_counter_value, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_CURSOR_POSITION:
        fprintf(f, ":SetCursorPosition ( ");
        PrintGenericObjectReference(f, v->a.set_cursor_position->target, 0);
        PrintGenericInteger(f, v->a.set_cursor_position->x_cursor, 0);
        PrintGenericInteger(f, v->a.set_cursor_position->y_cursor, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_CURSOR_SHAPE:
        fprintf(f, ":SetCursorShape ( ");
        PrintGenericObjectReference(f, v->a.set_cursor_shape->target, 0);
        PrintGenericObjectReference(
            f, v->a.set_cursor_shape->new_cursor_shape, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_DATA:
        fprintf(f, ":SetData ( ");
        PrintGenericObjectReference (f, (v->a.set_data->target), 0);
        PrintNewContent(f, (v->a.set_data->new_content), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_ENTRY_POINT:
        fprintf(f, ":SetEntryPoint ( ");
        PrintGenericObjectReference(f, v->a.set_entry_point->target, 0);
        PrintGenericInteger(f, v->a.set_entry_point->new_entry_point, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_FILL_COLOUR:
        fprintf(f, ":SetFillColour ( ");
        PrintGenericObjectReference(f, v->a.set_fill_colour->target, 0);
        if( v->a.set_fill_colour->new_fill_colour )
        {
            NewColour *data;
            data = v->a.set_fill_colour->new_fill_colour;
            switch(data->choiceId )
            {
            case NEWCOLOUR_NEW_COLOUR_INDEX:
                fprintf(f, ":NewColourIndex ");
                PrintGenericInteger(f, data->a.new_colour_index, 0);
                break;
            case NEWCOLOUR_NEW_ABSOLUTE_COLOUR:
                fprintf(f, ":NewAbsoluteColour ");
                PrintGenericOctetString(f, data->a.new_absolute_colour, 0);
                break;
            }
        }
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_FIRST_ITEM:
        fprintf(f, ":SetFirstItem ( ");
        PrintGenericObjectReference(f, v->a.set_first_item->target, 0);
        PrintGenericInteger(f, v->a.set_first_item->new_first_item, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_FONT_REF:
        fprintf(f, ":SetFontRef ( ");
        PrintGenericObjectReference(f, v->a.set_font_ref->target, 0);
        switch(v->a.set_font_ref->new_font->choiceId)
        {
        case NEWFONT_NEW_FONT_NAME:
            PrintGenericOctetString(
                f, v->a.set_font_ref->new_font->a.new_font_name, 0);
            break;
        case NEWFONT_NEW_FONT_REFERENCE:
            PrintGenericObjectReference(
                f, v->a.set_font_ref->new_font->a.new_font_reference, 0);
            break;
        }
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_HIGHLIGHT_STATUS:
        fprintf(f, ":SetHighlightStatus ( ");
        PrintGenericObjectReference(f, v->a.set_highlight_status->target, 0);
        PrintGenericBoolean(
            f, v->a.set_highlight_status->new_highlight_status, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_INTERACTION_STATUS:
        fprintf(f, ":SetInteractionStatus ( ");
        PrintGenericObjectReference(f, v->a.set_interaction_status->target, 0);
        PrintGenericBoolean(
            f, v->a.set_interaction_status->new_interaction_status, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_LABEL:
        fprintf(f, ":SetLabel ( ");
        PrintGenericObjectReference(f, v->a.set_label->target, 0);
        PrintGenericOctetString(f, v->a.set_label->new_label, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_LINE_COLOUR:
        fprintf(f, ":SetLineColour ( ");
        PrintGenericObjectReference(f, v->a.set_line_colour->target, 0);
        if( v->a.set_line_colour->new_line_colour )
        {
            NewColour *data;
            data = v->a.set_line_colour->new_line_colour;
            switch(data->choiceId )
            {
            case NEWCOLOUR_NEW_COLOUR_INDEX:
                fprintf(f, ":NewColourIndex ");
                PrintGenericInteger(f, data->a.new_colour_index, 0);
                break;
            case NEWCOLOUR_NEW_ABSOLUTE_COLOUR:
                fprintf(f, ":NewAbsoluteColour ");
                PrintGenericOctetString(f, data->a.new_absolute_colour, 0);
                break;
            }
        }
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_LINE_STYLE:
        fprintf(f, ":SetLineStyle ( ");
        PrintGenericObjectReference(f, v->a.set_line_style->target, 0);
        PrintGenericInteger(f, v->a.set_line_style->new_line_style, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_LINE_WIDTH:
        fprintf(f, ":SetLineWidth ( ");
        PrintGenericObjectReference(f, v->a.set_line_width->target, 0);
        PrintGenericInteger(f, v->a.set_line_width->new_line_width, 0);       
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_OVERWRITE_MODE:
        fprintf(f, ":SetOverwriteMode ( ");
        PrintGenericObjectReference(f, v->a.set_overwrite_mode->target, 0);
        PrintGenericBoolean(f, v->a.set_overwrite_mode->new_overwrite_mode, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_PALETTE_REF:
        fprintf(f, ":SetPaletteRef ( ");
        PrintGenericObjectReference(f, v->a.set_palette_ref->target, 0);
        PrintGenericObjectReference(
            f, v->a.set_palette_ref->new_palette_ref, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_PORTION:
        fprintf(f, ":SetPortion ( ");
        PrintGenericObjectReference(f, v->a.set_portion->target, 0);
        PrintGenericInteger(f, v->a.set_portion->new_portion, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_POSITION:
        fprintf(f, ":SetPosition ( ");
        PrintGenericObjectReference(f, v->a.set_position->target, 0);
        PrintGenericInteger(f, v->a.set_position->new_x_position, 0);
        PrintGenericInteger(f, v->a.set_position->new_y_position, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_SLIDER_VALUE:
        fprintf(f, ":SetSliderValue ( ");
        PrintGenericObjectReference(f, v->a.set_slider_value->target, 0);
        PrintGenericInteger(f, v->a.set_slider_value->new_slider_value, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_SPEED:
        fprintf(f, ":SetSpeed ( ");
        PrintGenericObjectReference(f, v->a.set_speed->target, 0);
        PrintGenericInteger(f, v->a.set_speed->new_speed->numerator, 0);
        if(  v->a.set_speed->new_speed->denominator )
            PrintGenericInteger(f, v->a.set_speed->new_speed->denominator, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_TIMER:
        fprintf(f, ":SetTimer ( ");
        PrintGenericObjectReference(f, v->a.set_timer->target, 0);
        PrintGenericInteger(f, v->a.set_timer->timer_id, 0);
        if( v->a.set_timer->new_timer )
        {
            PrintGenericInteger(f, v->a.set_timer->new_timer->timer_value, 0);
            if( v->a.set_timer->new_timer->absolute_time )
            {
                fprintf(f, ":AbsoluteTime ");
                PrintGenericBoolean(
                    f, v->a.set_timer->new_timer->absolute_time, 0);
            }
        }
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_TRANSPARENCY:
        fprintf(f, ":SetTransparency ( ");
        PrintGenericObjectReference(f, v->a.set_transparency->target, 0);
        PrintGenericInteger(f, v->a.set_transparency->new_transparency, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_VARIABLE:
    {
        NewVariableValue *data;
        fprintf(f, ":SetVariable ( ");
        PrintGenericObjectReference(f, v->a.set_variable->target, 0);
        data = v->a.set_variable->new_variable_value;
        switch(data->choiceId)
        {
        case NEWVARIABLEVALUE_NEW_GENERIC_INTEGER:
            fprintf(f, ":GInteger ");
            PrintGenericInteger(f, data->a.new_generic_integer, 0);
            break;
        case NEWVARIABLEVALUE_NEW_GENERIC_BOOLEAN:
            fprintf(f, ":GBoolean ");
            PrintGenericBoolean(f, data->a.new_generic_boolean, 0);
            break;
        case NEWVARIABLEVALUE_NEW_GENERIC_OCTET_STRING:
            fprintf(f, ":GOctetString ");
            PrintGenericOctetString(
                f, data->a.new_generic_octet_string, 0);
            break;
        case NEWVARIABLEVALUE_NEW_GENERIC_OBJECT_REFERENCE:
            fprintf(f, ":GObjectRef ");
            PrintGenericObjectReference(
                f, data->a.new_generic_object_reference, 0);
            break;
        case NEWVARIABLEVALUE_NEW_GENERIC_CONTENT_REFERENCE:
            fprintf(f, ":GContentRef ");
            PrintGenericContentReference(
                f, data->a.new_generic_content_reference, 0);
            break;
        }
        fprintf(f, ") ");
        break;
    }
    case ELEMENTARYACTION_SET_VOLUME:
        fprintf(f, ":SetVolume ( ");
        PrintGenericObjectReference(f, v->a.set_volume->target, 0);
        PrintGenericInteger(f, v->a.set_volume->new_volume, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SPAWN:
        fprintf(f, ":Spawn ( ");
        PrintGenericObjectReference (f, (v->a.spawn), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_STEP:
        fprintf(f, ":Step ( ");
        PrintGenericObjectReference(f, v->a.step->target, 0);
        PrintGenericInteger(f, v->a.step->nb_of_steps, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_STOP:
        fprintf(f, ":Stop ( ");
        PrintGenericObjectReference (f, (v->a.stop), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_STORE_PERSISTENT:
    {
        ObjectReference *tmp;
        fprintf(f, ":StorePersistent ( ");
        PrintGenericObjectReference(f, v->a.store_persistent->target, 0);
        PrintObjectReference(f, v->a.store_persistent->store_succeeded);
        fprintf(f, "( ");
        FOR_EACH_LIST_ELMT (tmp,v->a.store_persistent->in_variables){
            PrintObjectReference(f, tmp);
        }
        fprintf(f, ") ");
        PrintGenericOctetString(f, v->a.store_persistent->out_file_name, 0);
        fprintf(f, ") ");
        break;
    }
    case ELEMENTARYACTION_SUBTRACT:
        fprintf(f, ":Subtract ( ");
        PrintGenericObjectReference(f, v->a.subtract->target, 0);
        PrintGenericInteger(f, v->a.subtract->value, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_TEST_VARIABLE:
    {
        ComparisonValue *data;
        fprintf(f, ":TestVariable ( ");
        PrintGenericObjectReference(f, v->a.test_variable->target, 0);
        PrintGenericInteger(f,  v->a.test_variable->operator, 0);
        data = v->a.test_variable->comparison_value;
        switch(data->choiceId)
        {
        case COMPARISONVALUE_NEW_GENERIC_BOOLEAN:
            fprintf(f, ":GBoolean ");
            PrintGenericBoolean(f, data->a.new_generic_boolean, 0);
            break;
        case COMPARISONVALUE_NEW_GENERIC_INTEGER:
           fprintf(f, ":GInteger ");
            PrintGenericInteger(f, data->a.new_generic_integer, 0);
            break;
        case COMPARISONVALUE_NEW_GENERIC_OCTETSTRING:
            fprintf(f, ":GOctetString ");
            PrintGenericOctetString(
                f, data->a.new_generic_octetstring, 0);
            break;
        case COMPARISONVALUE_NEW_GENERIC_OBJECT_REFERENCE:
            fprintf(f, ":GObjectRef ");
            PrintGenericObjectReference(
                f, data->a.new_generic_object_reference, 0);
            break;
        case COMPARISONVALUE_NEW_GENERIC_CONTENT_REFERENCE:
            fprintf(f, ":GContentRef ");
            PrintGenericContentReference(
                f, data->a.new_generic_content_reference, 0);
            break;           
        }
        fprintf(f, ") ");
        if( include_comments ){
            if( v->a.test_variable->operator->choiceId
                == GENERICINTEGER_INTEGER )
                switch(v->a.test_variable->operator->a.integer)
                {
                case 1:fprintf(f, "// == " ); break;
                case 2:fprintf(f, "// != " ); break;
                case 3:fprintf(f, "// < " ); break;
                case 4:fprintf(f, "// <= " ); break;
                case 5:fprintf(f, "// > " ); break;
                case 6:fprintf(f, "// >= " ); break;
                }
        }

        break;
    }
    case ELEMENTARYACTION_TOGGLE:
        fprintf(f, ":Toggle ( ");
        PrintGenericObjectReference (f, (v->a.toggle), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_TOGGLE_ITEM:
        fprintf(f, ":ToggleItem ( ");
        PrintGenericObjectReference(f, v->a.toggle_item->target, 0);
        PrintGenericInteger(f, v->a.toggle_item->item_index, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_TRANSITION_TO:
        fprintf(f, ":TransitionTo ( ");
        PrintGenericObjectReference(f, v->a.transition_to->target, 0);
        PrintConnectionTagOrNull(
            f, v->a.transition_to->connection_tag_or_null, 0);
        if( v->a.transition_to->transition_effect )
            PrintGenericInteger(f, v->a.transition_to->transition_effect, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_UNLOAD:
        fprintf(f, ":Unload ( ");
        PrintGenericObjectReference (f, (v->a.unload), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_UNLOCK_SCREEN:
        fprintf(f, ":UnlockScreen ( ");
        PrintGenericObjectReference (f, (v->a.unlock_screen), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_BACKGROUND_COLOUR:
        fprintf(f, ":SetBackgroundColour ( ");
        PrintGenericObjectReference (
            f, (v->a.set_background_colour->target), 0);
        if( v->a.set_background_colour->new_background_colour )
        {
            NewColour *data;
            data = v->a.set_background_colour->new_background_colour;
            switch(data->choiceId )
            {
            case NEWCOLOUR_NEW_COLOUR_INDEX:
                fprintf(f, ":NewColourIndex ");
                PrintGenericInteger(f, data->a.new_colour_index, 0);
                break;
            case NEWCOLOUR_NEW_ABSOLUTE_COLOUR:
                fprintf(f, ":NewAbsoluteColour ");
                PrintGenericOctetString(f, data->a.new_absolute_colour, 0);
                break;
            }
        }
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_CELL_POSITION:
        fprintf(f, ":SetCellPosition ( ");
        PrintGenericObjectReference (f, (v->a.set_cell_position->target), 0);
        PrintGenericInteger(f, (v->a.set_cell_position->index), 0);
        PrintGenericInteger(f, (v->a.set_cell_position->new_x_position), 0);
        PrintGenericInteger(f, (v->a.set_cell_position->new_y_position), 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_INPUT_REGISTER:
        fprintf(f, ":SetInputReg ( ");
        PrintGenericObjectReference (f, (v->a.set_input_register->target), 0);
        PrintGenericInteger(f, v->a.set_input_register->new_input_register, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_TEXT_COLOUR:
        fprintf(f, ":SetTextColour ( ");
        PrintGenericObjectReference (f, (v->a.set_text_colour->target), 0);
        if( v->a.set_text_colour->new_text_colour )
        {
            NewColour *data;
            data = v->a.set_text_colour->new_text_colour;
            switch(data->choiceId )
            {
            case NEWCOLOUR_NEW_COLOUR_INDEX:
                fprintf(f, ":NewColourIndex ");
                PrintGenericInteger(f, data->a.new_colour_index, 0);
                break;
            case NEWCOLOUR_NEW_ABSOLUTE_COLOUR:
                fprintf(f, ":NewAbsoluteColour ");
                PrintGenericOctetString(f, data->a.new_absolute_colour, 0);
                break;
            }
        }
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_FONT_ATTRIBUTES:
        fprintf(f, ":SetFontAttributes ( ");
        PrintGenericObjectReference (f, v->a.set_font_attributes->target, 0);
        PrintGenericOctetString(
            f, v->a.set_font_attributes->new_font_attributes, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_VIDEO_DECODE_OFFSET:
        fprintf(f, ":SetVideoDecodeOffset ( ");
        PrintGenericObjectReference (f, v->a.set_position_offset->target, 0);
        PrintGenericInteger(f, v->a.set_position_offset->new_x_offset, 0);
        PrintGenericInteger(f, v->a.set_position_offset->new_y_offset, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_VIDEO_DECODE_OFFSET:
        fprintf(f, ":GetVideoDecodeOffset ( ");
        PrintGenericObjectReference (f, v->a.get_position_offset->target, 0);
        PrintObjectReference(f, v->a.get_position_offset->x_offset_var);
        PrintObjectReference(f, v->a.get_position_offset->y_offset_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_FOCUS_POSITION:
        fprintf(f, ":SetFocusPosition ( ");
        PrintGenericObjectReference (f, v->a.set_focus_position->target, 0);
        PrintGenericInteger(f, v->a.set_focus_position->new_focus_position, 0);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_GET_FOCUS_POSITION:
        fprintf(f, ":GetFocusPosition ( ");
        PrintGenericObjectReference (f, v->a.get_focus_position->target, 0);
        PrintObjectReference (f, v->a.get_focus_position->focus_position_var);
        fprintf(f, ") ");
        break;
        
    case ELEMENTARYACTION_SET_BITMAP_DECODE_OFFSET:
        fprintf(f, ":SetBitmapDecodeOffset ( ");
        PrintGenericObjectReference (f, v->a.set_position_offset->target, 0);
        PrintGenericInteger(f, v->a.set_position_offset->new_x_offset, 0);
        PrintGenericInteger(f, v->a.set_position_offset->new_y_offset, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_BITMAP_DECODE_OFFSET:
        fprintf(f, ":GetBitmapDecodeOffset ( ");
        PrintGenericObjectReference (f, v->a.get_position_offset->target, 0);
        PrintObjectReference(f, v->a.get_position_offset->x_offset_var);
        PrintObjectReference(f, v->a.get_position_offset->y_offset_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_SLIDER_PARAMETERS:
        fprintf(f, ":SetSliderParameters ( ");
        PrintGenericObjectReference (f, v->a.set_slider_parameters->target, 0);
        PrintGenericInteger(f, v->a.set_slider_parameters->new_min_value, 0);
        PrintGenericInteger(f, v->a.set_slider_parameters->new_max_value, 0);
        PrintGenericInteger(f, v->a.set_slider_parameters->new_step_size, 0);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_SET_DESKTOP_COLOUR:
        fprintf(f, ":SetDesktopColour ( ");
        PrintGenericObjectReference (f, (v->a.set_desktop_colour->target), 0);
        if( v->a.set_desktop_colour->new_desktop_colour )
        {
            NewColour *data;
            data = v->a.set_desktop_colour->new_desktop_colour;
            switch(data->choiceId )
            {
            case NEWCOLOUR_NEW_COLOUR_INDEX:
                fprintf(f, ":NewColourIndex ");
                PrintGenericInteger(f, data->a.new_colour_index, 0);
                break;
            case NEWCOLOUR_NEW_ABSOLUTE_COLOUR:
                fprintf(f, ":NewAbsoluteColour ");
                PrintGenericOctetString(f, data->a.new_absolute_colour, 0);
                break;
            }
        }
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_COUNTER_POSITION:
        fprintf(f, ":GetCounterPosition ( ");
        PrintGenericObjectReference (f, v->a.get_counter_position->target, 0);
        PrintObjectReference(f, v->a.get_counter_position->counter_position_var);
        fprintf(f, ") ");
        break;

    case ELEMENTARYACTION_GET_COUNTER_MAX_POSITION:
        fprintf(f, ":GetCounterMaxPosition ( ");
        PrintGenericObjectReference (f, v->a.get_counter_max_position->target, 0);
        PrintObjectReference(f, v->a.get_counter_max_position->counter_max_position_var);
        fprintf(f, ") ");
        break;

    }
    fprintf(f, "\n");
}  /* PrintElementaryAction */

static void
PrintActionClass PARAMS ((f, v, indent),
FILE* f _AND_
ActionClass *v _AND_
unsigned short int indent)
{
    ElementaryAction *tmp;
    if (v == NULL)
        return;
    fprintf(f, "(\n");
    FOR_EACH_LIST_ELMT (tmp, v)
        PrintElementaryAction (f, tmp, indent + 2);
    Indent (f, indent);
    fprintf (f,")\n");
}  /* PrintActionClass */

/*
        ( null )
        ( (
            :SetData ()
            :TransitionTo ()
          )
        )
        ( null ) I
*/
static void
PrintActionSlots(FILE* f, AsnList *list, unsigned short int indent)
{
    ActionSlot *tmp;
    int ii = 0;
    
    FOR_EACH_LIST_ELMT (tmp, list)
    {
        if( include_comments ){
            Indent (f, indent);
            fprintf(f, "// Action Slot %d\n", ++ii);
        }
        Indent (f, indent);
        switch( tmp->choiceId )
        {
        case ACTIONSLOT_ACTION_CLASS:
            PrintActionClass (f, tmp->a.action_class, indent);
            break;
        case ACTIONSLOT_NULL:
            fprintf(f, "null\n");
            break;
        }
    }
}

static void
PrintStandardIdentifier PARAMS ((f, v, indent),
                                FILE* f _AND_
                                StandardIdentifier *v _AND_
                                unsigned short int indent)
{
    if (v == NULL)
        return;

    Indent (f, indent);
    _PrintAsnInt (f, (&v->joint_iso_itu), 0);
    fprintf (f," ");
    _PrintAsnInt (f, (&v->mheg), 0);
    fprintf (f," ");
}  /* PrintStandardIdentifier */

static void
PrintSceneCoordinateSystem PARAMS ((f, v, indent),
                                   FILE* f _AND_
                                   SceneCoordinateSystem *v _AND_
                                   unsigned short int indent)
{
    if (v == NULL)
        return;

    Indent (f, indent);
    _PrintAsnInt (f, (&v->x_scene), 0);
    fprintf (f," ");
    _PrintAsnInt (f, (&v->y_scene), 0);
    fprintf (f," ");
}  /* PrintSceneCoordinateSystem */
static void
PrintAspectRatio PARAMS ((f, v, indent),
                         FILE* f _AND_
                         AspectRatio *v _AND_
                         unsigned short int indent)
{
    if (v == NULL)
        return;

    Indent (f, indent);
    _PrintAsnInt (f, (&v->width), 0);
    fprintf (f," ");
    _PrintAsnInt (f, (&v->height), 0);
    fprintf (f," ");
}  /* PrintAspectRatio */
static void
PrintNextScene PARAMS ((f, v, indent),
                       FILE* f _AND_
                       NextScene *v _AND_
                       unsigned short int indent)
{
    if (v == NULL)
        return;

    fprintf (f,"( ");
    PrintQPrintableOctetString (f, (&v->scene_ref));
    _PrintAsnInt (f, (&v->scene_weight), 0);
    fprintf (f," ) ");
}  /* PrintNextScene */
static void
PrintEventData PARAMS ((f, v, indent),
                       FILE* f _AND_
                       EventData *v _AND_
                       unsigned short int indent)
{
    switch (v->choiceId)
    {
    case EVENTDATA_OCTETSTRING:
        PrintQPrintableOctetString (f, (v->a.octetstring));
        break;

    case EVENTDATA_BOOLEAN:
        PrintAsnBool (f, (&v->a.boolean), 0);
        fprintf(f, " ");
        break;

    case EVENTDATA_INTEGER:
        _PrintAsnInt (f, (&v->a.integer), 0);
        fprintf(f, " ");
        break;

    }
}  /* PrintEventData */
static void
PrintMovement PARAMS ((f, v, indent),
                      FILE* f _AND_
                      Movement *v _AND_
                      unsigned short int indent)
{
    AsnInt *tmp;
    if (v == NULL)
        return;
    fprintf(f, "( ");
    FOR_EACH_LIST_ELMT (tmp, v)
        {
            _PrintAsnInt (f, tmp, 0);
            fprintf(f, " ");
        }
    fprintf (f,") ");
}  /* PrintMovement */
static void
PrintOriginalBoxSize PARAMS ((f, v, indent),
                             FILE* f _AND_
                             OriginalBoxSize *v _AND_
                             unsigned short int indent)
{
    if (v == NULL)
        return;

    _PrintAsnInt (f, (&v->x_length), 0);
    fprintf (f, " ");
    _PrintAsnInt (f, (&v->y_length), 0);
    fprintf (f," ");
}  /* PrintOriginalBoxSize */

static void
PrintColour PARAMS ((f, v, indent),
                    FILE* f _AND_
                    Colour *v _AND_
                    unsigned short int indent)
{
    switch (v->choiceId)
    {
    case COLOUR_COLOUR_INDEX:
        _PrintAsnInt (f, (&v->a.colour_index), 0);
        fprintf(f, " ");
        break;

    case COLOUR_ABSOLUTE_COLOUR:
        PrintQPrintableBinaryOctetString (f, (v->a.absolute_colour));
        break;

    }
}  /* PrintColour */

static void
PrintXYPosition PARAMS ((f, v, indent),
                        FILE* f _AND_
                        XYPosition *v _AND_
                        unsigned short int indent)
{
    if (v == NULL)
        return;

    _PrintAsnInt (f, (&v->x_position), 0);
    fprintf (f," ");
    _PrintAsnInt (f, (&v->y_position), 0);
    fprintf (f," ");
}  /* PrintXYPosition */



static void
PrintSceneClassSeqOf PARAMS ((f, v, indent),
                             FILE* f _AND_
                             SceneClassSeqOf *v _AND_
                             unsigned short int indent)
{
    NextScene *tmp;
    if (v == NULL)
        return;
    fprintf (f,"(\n");
    FOR_EACH_LIST_ELMT (tmp, v)
        {
            PrintNextScene (f, tmp, indent + 2);
            fprintf (f,"\n");
        
        }
    Indent(f, indent);
    fprintf (f,") ");
}  /* PrintSceneClassSeqOf */

static void
PrintReferencedContent PARAMS ((f, v, indent),
                               FILE* f _AND_
                               ReferencedContent *v _AND_
                               unsigned short int indent)
{
    if (v == NULL)
        return;

    fprintf (f,":ContentRef ( ");

    PrintQPrintableOctetString (f, (&v->content_reference));
    if (NOT_NULL ((v->content_size)))
    {
        fprintf (f,":ContentSize ");
        _PrintAsnInt (f, (v->content_size), 0);
        fprintf (f," ");
    }
    if (NOT_NULL ((v->content_cache_priority)))
    {
        fprintf (f,":CCPriority ");
        _PrintAsnInt (f, (v->content_cache_priority), 0);
        fprintf (f," ");
    }
    fprintf (f,") ");
}  /* PrintReferencedContent */


static void
PrintFontBody PARAMS ((f, v, indent),
                      FILE* f _AND_
                      FontBody *v _AND_
                      unsigned short int indent)
{
    switch (v->choiceId)
    {
    case FONTBODY_DIRECT_FONT:
        PrintQPrintableOctetString (f, (v->a.direct_font));
        break;

    case FONTBODY_INDIRECT_FONT:
        PrintObjectReference (f, (v->a.indirect_font));
        break;

    }
}  /* PrintFontBody */

static void
PrintContentBody PARAMS ((f, v, indent),
                         FILE* f _AND_
                         ContentBody *v _AND_
                         unsigned short int indent)
{
    switch (v->choiceId)
    {
    case CONTENTBODY_INCLUDED_CONTENT:
        PrintQPrintableOctetString (f, (v->a.included_content));
        break;

    case CONTENTBODY_REFERENCED_CONTENT:
        PrintReferencedContent (f, (v->a.referenced_content), 0);
        break;

    }
}  /* PrintContentBody */

#define PrintRootClass PrintObjectReference

#define PrintIngredient(f,v,indent)                     \
    PrintRootClass (f, (v->rootClass));                 \
    fprintf (f, "\n");                                  \
    if (NOT_NULL ((v->initially_active)))               \
    {                                                   \
    Indent (f, indent );                                \
    fprintf (f,":InitiallyActive ");                    \
    PrintAsnBool (f, (v->initially_active), 0);         \
    fprintf (f, "\n");                                  \
    }                                                   \
    if (NOT_NULL ((v->content_hook)))                   \
    {                                                   \
    Indent (f, indent );                                \
    fprintf (f,":CHook ");                              \
    _PrintAsnInt (f, (v->content_hook), 0);              \
    fprintf (f, "\n");                                  \
    }                                                   \
    if (NOT_NULL ((v->original_content)))               \
    {                                                   \
    Indent (f, indent);                                 \
    fprintf (f,":OrigContent ");                        \
    PrintContentBody (f, (v->original_content), 0);     \
    fprintf (f, "\n");                                  \
    }                                                   \
    if (NOT_NULL ((v->shared)))                         \
    {                                                   \
    Indent (f, indent);                                 \
    fprintf (f,":Shared ");                             \
    PrintAsnBool (f, (v->shared), 0);                   \
    fprintf (f, "\n");                                  \
    }

static void
PrintResidentProgramClass PARAMS ((f, v, indent),
                                  FILE* f _AND_
                                  ProgramClass *v _AND_
                                  unsigned short int indent)
{
    if (v == NULL)
        return;

    PrintIngredient(f,v,indent);
    
    Indent (f, indent );
    fprintf (f,":Name ");
    PrintQPrintableOctetString (f, (&v->name));
    fprintf (f, "\n");

    if (NOT_NULL ((v->initially_available)))
    {
        Indent (f, indent);
        fprintf (f,":InitiallyAvailable ");
        PrintAsnBool (f, (v->initially_available), 0);
        fprintf (f, "\n");
    }
}  /* PrintProgramClass */

static void
PrintInterchangedProgramClass PARAMS ((f, v, indent),
                                      FILE* f _AND_
                                      ProgramClass *v _AND_
                                      unsigned short int indent)
{
    if (v == NULL)
        return;

    PrintIngredient(f,v,indent);
    
    Indent (f, indent + 2);
    fprintf (f,":Name ");
    PrintQPrintableOctetString (f, (&v->name));
    fprintf (f, "\n");

    if (NOT_NULL ((v->initially_available)))
    {
        Indent (f, indent + 2);
        fprintf (f,":InitiallyAvailable ");
        PrintAsnBool (f, (v->initially_available), 0);
        fprintf (f, "\n");
    }
}  /* PrintProgramClass */

static void
PrintRemoteProgramClass PARAMS ((f, v, indent),
                                FILE* f _AND_
                                RemoteProgramClass *v _AND_
                                unsigned short int indent)
{
    if (v == NULL)
        return;
    
    PrintIngredient(f,v,indent);
    
    Indent (f, indent + 2);
    fprintf (f,":Name ");
    PrintQPrintableOctetString (f, (&v->name));
    fprintf (f, "\n");

    if (NOT_NULL ((v->initially_available)))
    {
        Indent (f, indent + 2);
        fprintf (f,":InitiallyAvailable ");
        PrintAsnBool (f, (v->initially_available), 0);
        fprintf (f, "\n");
    }

    if (NOT_NULL ((v->program_connection_tag)))
    {
        Indent (f, indent + 2);
        fprintf (f,":ConnectionTag ");
        _PrintAsnInt (f, (v->program_connection_tag), 0);
        fprintf (f, "\n");
    }

}  /* PrintRemoteProgramClass */

static void
PrintOriginalValue PARAMS ((f, v, indent),
                           FILE* f _AND_
                           OriginalValue *v _AND_
                           unsigned short int indent)
{
    switch (v->choiceId)
    {
    case ORIGINALVALUE_BOOLEAN:
        PrintAsnBool (f, (&v->a.boolean), 0);
        fprintf(f, " ");
        break;

    case ORIGINALVALUE_INTEGER:
        _PrintAsnInt (f, (&v->a.integer), 0);
        fprintf(f, " ");
        break;

    case ORIGINALVALUE_OCTETSTRING:
        PrintQPrintableOctetString (f, (v->a.octetstring));
        break;

    case ORIGINALVALUE_OBJECT_REFERENCE:
        fprintf (f,":ObjectRef ");
        PrintObjectReference (f, (v->a.object_reference));
        break;

    case ORIGINALVALUE_CONTENT_REFERENCE:
        fprintf (f,":ContentRef ");
        PrintQPrintableOctetString (f, (v->a.content_reference));
        break;

    }
}  /* PrintOriginalValue */

#define PrintVariable(f, v, indent)                     \
    PrintIngredient(f, v, indent);                      \
    Indent (f, indent);                                 \
    fprintf (f,":OrigValue ");                          \
    PrintOriginalValue (f, (v->original_value), 0);     \
    fprintf (f,"\n");

#define PrintTokenGroup(f, v, indent)                                   \
    if (v == NULL)                                                      \
        return;                                                         \
                                                                        \
    PrintIngredient(f, v, indent);                                      \
                                                                        \
    if (NOT_NULL ((v->movement_table)))                                 \
    {                                                                   \
        Movement *tmp;                                                  \
                                                                        \
        Indent (f, indent);                                             \
        fprintf(f, ":MovementTable (\n");                               \
        FOR_EACH_LIST_ELMT (tmp, v->movement_table) {                   \
            Indent (f, indent + 2);                                     \
            PrintMovement (f, tmp, 0);                                  \
            fprintf (f,"\n");                                           \
        }                                                               \
        Indent (f, indent );                                            \
        fprintf (f,")\n");                                              \
    }                                                                   \
                                                                        \
    if (NOT_NULL ((v->token_group_items)))                              \
    {                                                                   \
    Indent (f, indent);                                                 \
    fprintf (f,":TokenGroupItems (\n");                                 \
    {                                                                   \
        TokenGroupItem *tmp;                                            \
         int ii = 0;                                                    \
         FOR_EACH_LIST_ELMT (tmp, v->token_group_items) {               \
             if( include_comments ){                                    \
                 Indent (f, indent + 2);                                \
                 fprintf(f, "// TokenGroup Item %d\n", ++ii);           \
             }                                                          \
             Indent (f, indent + 2);                                    \
             fprintf (f,"( ");                                          \
             PrintObjectReference(f, tmp->a_visible);                   \
             if( NOT_NULL(tmp->action_slots))                           \
             {                                                          \
                 fprintf (f,"\n");                                      \
                 Indent (f, indent + 4);                                \
                 fprintf (f,":ActionSlots (\n");                        \
                 PrintActionSlots (f, tmp->action_slots, indent + 6);   \
                 Indent (f, indent + 4);                                \
                 fprintf (f,")\n");                                     \
                 Indent (f, indent + 2);                                \
             }                                                          \
             fprintf (f,")\n");                                         \
         }                                                              \
    }                                                                   \
    Indent (f, indent);                                                 \
    fprintf (f,")\n");                                                  \
    }                                                                   \
    if (NOT_NULL ((v->no_token_action_slots)))                          \
    {                                                                   \
        Indent (f, indent);                                             \
        fprintf (f,":NoTokenActionSlots (\n");                          \
        PrintActionSlots (f, (v->no_token_action_slots), indent + 2);   \
        Indent(f, indent);                                              \
        fprintf(f, ")\n");                                              \
    }

static void
PrintListGroupClass PARAMS ((f, v, indent),
FILE* f _AND_
ListGroupClass *v _AND_
unsigned short int indent)
{
    XYPosition *tmp;
    
    if (v == NULL)
        return;

    PrintTokenGroup(f, v, indent);

    Indent (f, indent);
    fprintf (f,":Positions ( ");
    FOR_EACH_LIST_ELMT (tmp, v->positions){
        fprintf(f, "( ");
        PrintXYPosition(f, tmp, 0);
        fprintf(f, ") ");
    }
    fprintf (f,"\n");
    Indent (f, indent + 11);
    fprintf (f,")\n");
    if (NOT_NULL ((v->wrap_around)))
    {
    Indent (f, indent);
    fprintf (f,":WrapAround ");
    PrintAsnBool (f, (v->wrap_around), 0);
    fprintf (f,"\n");
    }
    if (NOT_NULL ((v->multiple_selection)))
    {
    Indent (f, indent + stdIndentG);
    fprintf (f,":MultipleSelection ");
    PrintAsnBool (f, (v->multiple_selection), 0);
    fprintf (f,"\n");
    }
}  /* PrintListGroupClass */

#define PrintVisible(f, v, indent)                              \
    PrintIngredient(f, v, indent);                              \
                                                                \
    Indent (f, indent);                                         \
    fprintf(f, ":OrigBoxSize ");                                \
    PrintOriginalBoxSize (f, (v->original_box_size), 0);        \
    fprintf(f, "\n");                                           \
    if (NOT_NULL ((v->original_position)))                      \
    {                                                           \
    Indent (f, indent);                                         \
    fprintf (f,":OrigPosition ");                               \
    PrintXYPosition (f, (v->original_position), 0);             \
    fprintf(f, "\n");                                           \
    }                                                           \
    if (NOT_NULL ((v->original_palette_ref)))                   \
    {                                                           \
    Indent (f, indent);                                         \
    fprintf (f,":OrigPaletteRef ");                             \
    PrintObjectReference (f, (v->original_palette_ref));        \
    fprintf (f,"\n");                                           \
    }
    
static void
PrintBitmapClass PARAMS ((f, v, indent),
                         FILE* f _AND_
                         BitmapClass *v _AND_
                         unsigned short int indent)
{
    if (v == NULL)
        return;

    PrintVisible(f, v, indent);
    if (NOT_NULL ((v->tiling)))
    {
        Indent (f, indent);
        fprintf (f,":Tiling ");
        PrintAsnBool (f, (v->tiling), 0);
        fprintf (f,"\n");
    }
    if (NOT_NULL ((v->original_transparency)))
    {
        Indent (f, indent);
        fprintf (f,":OrigTransparency ");
        _PrintAsnInt (f, (v->original_transparency), 0);
        fprintf (f,"\n");
    }
}  /* PrintBitmapClass */

#define PrintLineArt(f, v, indent)                                           \
    PrintVisible(f,v,indent);                                                \
                                                                             \
    if (NOT_NULL ((v->bordered_bounding_box)))                               \
    {                                                                        \
    Indent (f, indent);                                                      \
    fprintf (f,":BBBox ");                                                   \
    PrintAsnBool (f, (v->bordered_bounding_box), 0);                         \
    fprintf (f,"\n");                                                        \
    }                                                                        \
    if (NOT_NULL ((v->original_line_width)))                                 \
    {                                                                        \
    Indent (f, indent);                                                      \
    fprintf (f,":OrigLineWidth ");                                           \
    _PrintAsnInt (f, (v->original_line_width), 0);                            \
    fprintf (f,"\n");                                                        \
    }                                                                        \
    if (NOT_NULL ((v->original_line_style)))                                 \
    {                                                                        \
    Indent (f, indent);                                                      \
    fprintf (f,":OrigLineStyle ");                                           \
    _PrintAsnInt (f, (v->original_line_style), 0);                            \
    fprintf (f,"\n");                                                        \
    }                                                                        \
    if (NOT_NULL ((v->original_ref_line_colour)))                            \
    {                                                                        \
    Indent (f, indent);                                                      \
    fprintf (f,":OrigRefLineColour ");                                       \
    PrintColour (f, (v->original_ref_line_colour), 0);                       \
    fprintf (f,"\n");                                                        \
    }                                                                        \
    if (NOT_NULL ((v->original_ref_fill_colour)))                            \
    {                                                                        \
    Indent (f, indent);                                                      \
    fprintf (f,":OrigRefFillColour ");                                       \
    PrintColour (f, (v->original_ref_fill_colour), 0);                       \
    fprintf (f,"\n");                                                        \
    }

#define PrintText(f, v, indent)                                               \
    PrintVisible(f, v, indent)                                                \
    if (NOT_NULL ((v->original_font)))                                        \
    {                                                                         \
    Indent (f, indent);                                                       \
    fprintf (f,":OrigFont ");                                                 \
    PrintFontBody (f, (v->original_font), 0);                                 \
    fprintf(f, "\n");                                                         \
    }                                                                         \
    if (ASNOCTS_PRESENT ((&v->font_attributes)))                              \
    {                                                                         \
    Indent (f, indent);                                                       \
    fprintf (f,":FontAttributes ");                                           \
    PrintQPrintableOctetString (f, (&v->font_attributes));                    \
    fprintf(f, "\n");                                                         \
    }                                                                         \
    if (NOT_NULL ((v->text_colour)))                                          \
    {                                                                         \
    Indent (f, indent);                                                       \
    fprintf (f,":TextColour ");                                               \
    PrintColour (f, (v->text_colour), 0);                                     \
    fprintf(f, "\n");                                                         \
    }                                                                         \
    if (NOT_NULL ((v->background_colour)))                                    \
    {                                                                         \
    Indent (f, indent);                                                       \
    fprintf (f,":BackgroundColour ");                                         \
    PrintColour (f, (v->background_colour), 0);                               \
    fprintf(f, "\n");                                                         \
    }                                                                         \
    if (NOT_NULL ((v->character_set)))                                        \
    {                                                                         \
    Indent (f, indent);                                                       \
    fprintf (f,":CharacterSet ");                                             \
    _PrintAsnInt (f, (v->character_set), 0);                                   \
    fprintf(f, "\n");                                                         \
    }                                                                         \
    if (NOT_NULL ((v->horizontal_justification)))                             \
    {                                                                         \
    Indent (f, indent);                                                       \
    fprintf (f,":HJustification ");                                           \
    PrintJustification (f, *(v->horizontal_justification));                   \
    fprintf(f, "\n");                                                         \
    }                                                                         \
    if (NOT_NULL ((v->vertical_justification)))                               \
    {                                                                         \
    Indent (f, indent);                                                       \
    fprintf (f,":VJustification ");                                           \
    PrintJustification (f, *(v->vertical_justification));                     \
    fprintf(f, "\n");                                                         \
    }                                                                         \
    if (NOT_NULL ((v->line_orientation)))                                     \
    {                                                                         \
    Indent (f, indent);                                                       \
    fprintf (f,":LineOrientation ");                                          \
    PrintLineOrientation (f, *(v->line_orientation));                         \
    fprintf(f, "\n");                                                         \
    }                                                                         \
    if (NOT_NULL ((v->start_corner)))                                         \
    {                                                                         \
    Indent (f, indent);                                                       \
    fprintf (f,":StartCorner ");                                              \
    PrintStartCorner (f, *(v->start_corner));                                 \
    fprintf(f, "\n");                                                         \
    }                                                                         \
    if (NOT_NULL ((v->text_wrapping)))                                        \
    {                                                                         \
    Indent (f, indent);                                                       \
    fprintf (f,":TextWrapping ");                                             \
    PrintAsnBool (f, (v->text_wrapping), 0);                                  \
    fprintf(f, "\n");                                                         \
    }

static void
PrintAudioClass PARAMS ((f, v, indent),
                        FILE* f _AND_
                        AudioClass *v _AND_
                        unsigned short int indent)
{
    if (v == NULL)
        return;

    PrintIngredient(f, v, indent);
    
    Indent (f, indent);
    fprintf (f,":ComponentTag ");
    _PrintAsnInt (f, (&v->component_tag), 0);
    fprintf (f,"\n");
    if (NOT_NULL ((v->original_volume)))
    {
        Indent (f, indent);
        fprintf (f,":OrigVolume ");
        _PrintAsnInt (f, (v->original_volume), 0);
        fprintf (f,"\n");
    }
}  /* PrintAudioClass */

static void
PrintVideoClass PARAMS ((f, v, indent),
                        FILE* f _AND_
                        VideoClass *v _AND_
                        unsigned short int indent)
{
    if (v == NULL)
        return;

    PrintVisible(f, v, indent);
    
    Indent (f, indent);
    fprintf (f,":ComponentTag ");
    _PrintAsnInt (f, (&v->component_tag), 0);
    fprintf (f,"\n");
    if (NOT_NULL ((v->termination)))
    {
        Indent (f, indent);
        fprintf (f,":Termination ");
        PrintTermination (f, *(v->termination));
        fprintf (f,"\n");
    }
}  /* PrintVideoClass */

static void
PrintRTGraphicsClass PARAMS ((f, v, indent),
                             FILE* f _AND_
                             RTGraphicsClass *v _AND_
                             unsigned short int indent)
{
    if (v == NULL)
        return;

    PrintVisible(f, v, indent);
    
    Indent (f, indent);
    fprintf (f,":ComponentTag ");
    _PrintAsnInt (f, (&v->component_tag), 0);
    fprintf (f,"\n");
    if (NOT_NULL ((v->termination)))
    {
        Indent (f, indent);
        fprintf (f,":Termination ");
        PrintTermination (f, *(v->termination));
        fprintf (f,"\n");
    }
}  /* PrintRTGraphicsClass */

#define PrintInteractible(f, v, indent)                 \
    if (NOT_NULL ((v->engine_resp)))                    \
    {                                                   \
    Indent (f, indent);                                 \
    fprintf (f,":EngineResp ");                         \
    PrintAsnBool (f, (v->engine_resp), 0);              \
    fprintf (f, "\n");                                  \
    }                                                   \
    if (NOT_NULL ((v->highlight_ref_colour)))           \
    {                                                   \
    Indent (f, indent);                                 \
    fprintf (f,":HighlightRefColour ");                 \
    PrintColour (f, (v->highlight_ref_colour), 0);      \
    fprintf (f, "\n");                                  \
    }

static void
PrintSliderClass PARAMS ((f, v, indent),
                         FILE* f _AND_
                         SliderClass *v _AND_
                         unsigned short int indent)
{
    if (v == NULL)
        return;

    PrintVisible(f, v, indent);
    PrintInteractible(f, v, indent);
    
    Indent (f, indent);
    fprintf (f,":Orientation ");
    PrintOrientation (f, v->orientation);
    fprintf (f, "\n");
    Indent (f, indent);
    fprintf (f,":MaxValue ");
    _PrintAsnInt (f, (&v->max_value), 0);
    fprintf (f, "\n");
    if (NOT_NULL ((v->min_value)))
    {
        Indent (f, indent);
        fprintf (f,":MinValue ");
        _PrintAsnInt (f, (v->min_value), 0);
        fprintf (f, "\n");
    }
    if (NOT_NULL ((v->initial_value)))
    {
        Indent (f, indent);
        fprintf (f,":InitialValue ");
        _PrintAsnInt (f, (v->initial_value), 0);
        fprintf (f, "\n");
    }
    if (NOT_NULL ((v->initial_portion)))
    {
        Indent (f, indent);
        fprintf (f,":InitialPortion ");
        _PrintAsnInt (f, (v->initial_portion), 0);
        fprintf (f, "\n");
    }
    if (NOT_NULL ((v->step_size)))
    {
        Indent (f, indent);
        fprintf (f,":StepSize ");
        _PrintAsnInt (f, (v->step_size), 0);
        fprintf (f, "\n");
    }
    if (NOT_NULL ((v->slider_style)))
    {
        Indent (f, indent);
        fprintf (f,":SliderStyle ");
        PrintSliderStyle (f, *(v->slider_style));
        fprintf (f, "\n");
    }
    if (NOT_NULL ((v->slider_ref_colour)))
    {
        Indent (f, indent);
        fprintf (f,":SliderRefColour ");
        PrintColour (f, (v->slider_ref_colour), 0);
        fprintf (f, "\n");
    }
}  /* PrintSliderClass */

static void
PrintEntryFieldClass PARAMS ((f, v, indent),
                             FILE* f _AND_
                             EntryFieldClass *v _AND_
                             unsigned short int indent)
{
    if (v == NULL)
        return;

    PrintText(f, v, indent);
    PrintInteractible(f, v, indent);
    
    if (NOT_NULL ((v->input_type)))
    {
        Indent (f, indent);        
        fprintf (f,":InputType ");
        PrintInputType (f, *(v->input_type));
        fprintf (f,"\n");
    }
    if (ASNOCTS_PRESENT ((&v->char_list)))
    {
        Indent (f, indent);
        fprintf (f,":CharList ");
        PrintQPrintableOctetString (f, (&v->char_list));
        fprintf (f,"\n");
    }
    if (NOT_NULL ((v->obscured_input)))
    {
        Indent (f, indent);
        fprintf (f,":ObscuredInput ");
        PrintAsnBool (f, (v->obscured_input), 0);
        fprintf (f,"\n");
    }
    if (NOT_NULL ((v->max_length)))
    {
        Indent (f, indent);
        fprintf (f,":MaxLength ");
        _PrintAsnInt (f, (v->max_length), 0);
        fprintf (f,"\n");
    }
}  /* PrintEntryFieldClass */

static void
PrintHyperTextClass PARAMS ((f, v, indent),
                            FILE* f _AND_
                            HyperTextClass *v _AND_
                            unsigned short int indent)
{
    if (v == NULL)
        return;

    PrintText(f, v, indent);
    PrintInteractible(f, v, indent);
    
}  /* PrintHyperTextClass */

static void
PrintButtonClass PARAMS ((f, v, indent),
                         FILE* f _AND_
                         ButtonClass *v _AND_
                         unsigned short int indent)
{
    if (v == NULL)
        return;

    PrintVisible(f, v, indent);
    PrintInteractible(f, v, indent);

    if (NOT_NULL ((v->button_ref_colour)))
    {
        Indent (f, indent);
        fprintf (f,":ButtonRefColour ");
        PrintColour (f, (v->button_ref_colour), 0);
        fprintf (f,"\n");
    }
}  /* PrintButtonClass */

#define PrintHotspotClass PrintButtonClass

static void
PrintPushButtonClass PARAMS ((f, v, indent),
                             FILE* f _AND_
                             PushButtonClass *v _AND_
                             unsigned short int indent)
{
    if (v == NULL)
        return;

    PrintVisible(f, v, indent);
    PrintInteractible(f, v, indent);

    if (NOT_NULL ((v->button_ref_colour)))
    {
        Indent (f, indent);
        fprintf (f,":ButtonRefColour ");
        PrintColour (f, (v->button_ref_colour), 0);
        fprintf (f,"\n");
    }
    if (ASNOCTS_PRESENT ((&v->original_label)))
    {
        Indent (f, indent);
        fprintf (f,":OrigLabel ");
        PrintQPrintableOctetString (f, (&v->original_label));
        fprintf (f,"\n");
    }
    if (NOT_NULL ((v->character_set)))
    {
        Indent (f, indent);
        fprintf (f,":CharacterSet ");
        _PrintAsnInt (f, (v->character_set), 0);
        fprintf (f,"\n");
    }
}  /* PrintPushButtonClass */

static void
PrintSwitchButtonClass PARAMS ((f, v, indent),
                               FILE* f _AND_
                               SwitchButtonClass *v _AND_
                               unsigned short int indent)
{
    if (v == NULL)
        return;

    PrintVisible(f, v, indent);
    PrintInteractible(f, v, indent);

    if (NOT_NULL ((v->button_ref_colour)))
    {
        Indent (f, indent);
        fprintf (f,":ButtonRefColour ");
        PrintColour (f, (v->button_ref_colour), 0);
        fprintf (f,"\n");
    }
    if (ASNOCTS_PRESENT ((&v->original_label)))
    {
        Indent (f, indent);
        fprintf (f,":OrigLabel ");
        PrintQPrintableOctetString (f, (&v->original_label));
        fprintf (f,"\n");
    }
    if (NOT_NULL ((v->character_set)))
    {
        Indent (f, indent);
        fprintf (f,":CharacterSet ");
        _PrintAsnInt (f, (v->character_set), 0);
        fprintf (f,"\n");
    }
    Indent (f, indent);
    fprintf (f,":ButtonStyle ");
    PrintButtonStyle (f, v->button_style);
    fprintf (f,"\n");
}  /* PrintSwitchButtonClass */

static void
PrintStreamComponent PARAMS ((f, v, indent),
FILE* f _AND_
StreamComponent *v _AND_
unsigned short int indent)
{
    Indent(f, indent);
    switch (v->choiceId)
    {
    case STREAMCOMPONENT_AUDIO:
        fprintf (f,"{ :Audio ");
        PrintAudioClass (f, (v->a.audio), indent + 2);
        break;
        
    case STREAMCOMPONENT_VIDEO:
        fprintf (f,"{ :Video ");
        PrintVideoClass (f, (v->a.video), indent + 2);
        break;
        
    case STREAMCOMPONENT_RTGRAPHICS:
        fprintf (f,"{ :RTGraphics ");
        PrintRTGraphicsClass (f, (v->a.rtgraphics), indent + 2);
        break;
    }
    Indent(f, indent);
    fprintf (f,"}\n");
}  /* PrintStreamComponent */


static void
PrintStreamClassSeqOf PARAMS ((f, v, indent),
FILE* f _AND_
StreamClassSeqOf *v _AND_
unsigned short int indent)
{
    StreamComponent *tmp;
    if (v == NULL)
        return;
    fprintf (f,"(\n");
    FOR_EACH_LIST_ELMT (tmp, v)
    {
        PrintStreamComponent (f, tmp, indent + 2);
    }
    Indent (f, indent);
    fprintf (f,")\n");
}  /* PrintStreamClassSeqOf */


static void
PrintStreamClass PARAMS ((f, v, indent),
FILE* f _AND_
StreamClass *v _AND_
unsigned short int indent)
{
    if (v == NULL)
        return;

    PrintIngredient(f, v, indent);
    
    if (NOT_NULL ((v->multiplex)))
    {
    Indent (f, indent);
    fprintf (f,":Multiplex ");
    PrintStreamClassSeqOf (f, (v->multiplex), indent);
    }
    if (NOT_NULL ((v->storage)))
    {
    Indent (f, indent);
    fprintf (f,":Storage ");
    PrintStorage (f, *v->storage);
    fprintf(f, "\n");
    }
    if (NOT_NULL ((v->looping)))
    {
    Indent (f, indent);
     fprintf (f,":Looping ");
    _PrintAsnInt (f, (v->looping), 0);
    fprintf(f, "\n");
    }
}  /* PrintStreamClass */

static void
PrintLinkClass PARAMS ((f, v, indent),
FILE* f _AND_
LinkClass *v _AND_
unsigned short int indent)
{
    if (v == NULL)
        return;

    PrintIngredient(f,v,indent);
        
    Indent (f, indent);
    fprintf (f,":EventSource ");
    PrintObjectReference (f, (v->link_condition->event_source));
    fprintf (f, "\n");

    Indent (f, indent );
    fprintf (f, ":EventType ");
    PrintEventType (f, v->link_condition->event_type);
    fprintf (f, "\n");
    
    if (NOT_NULL ((v->link_condition->event_data)))
    {
        Indent (f, indent );
        fprintf (f,":EventData ");
        PrintEventData (f, (v->link_condition->event_data), 0);
        fprintf (f,"\n");
    }
    Indent (f, indent );
    fprintf (f,":LinkEffect ");
    PrintActionClass (f, (v->link_effect), indent );
}  /* PrintLinkClass */

static void
PrintGroupItem PARAMS ((f, v, indent),
FILE* f _AND_
GroupItem *v _AND_
unsigned short int indent)
{
    Indent(f, indent);
    fprintf (f,"{ ");
    switch (v->choiceId)
    {
    case GROUPITEM_RESIDENT_PROGRAM:
        fprintf(f, ":ResidentPrg ");
        PrintResidentProgramClass (f, (v->a.resident_program), indent + 2);
        break;

    case GROUPITEM_REMOTE_PROGRAM:
        fprintf(f, ":RemotePrg ");
        PrintRemoteProgramClass (f, (v->a.remote_program), indent + 2);
        break;

    case GROUPITEM_INTERCHANGED_PROGRAM:
        fprintf(f, ":InterchgPrg ");
        PrintInterchangedProgramClass (f, (v->a.interchanged_program), indent + 2 );
        break;

    case GROUPITEM_PALETTE:
        fprintf(f, ":Palette ");
        PrintIngredient (f, (v->a.palette), indent + 2);
        break;

    case GROUPITEM_FONT:
        fprintf(f, ":Font ");
        PrintIngredient (f, (v->a.font_class), indent + 2  );
        break;

    case GROUPITEM_CURSOR_SHAPE:
        fprintf(f, ":CursorShape ");
        PrintIngredient (f, (v->a.cursor_shape), indent + 2 );
        break;

    case GROUPITEM_BOOLEAN_VARIABLE:
        fprintf(f, ":BooleanVar ");
        PrintVariable (f, (v->a.boolean_variable), indent + 2  );
        break;

    case GROUPITEM_INTEGER_VARIABLE:
        fprintf(f, ":IntegerVar ");
        PrintVariable (f, (v->a.integer_variable), indent + 2  );
        break;

    case GROUPITEM_OCTET_STRING_VARIABLE:
        fprintf(f, ":OStringVar ");
        PrintVariable (f, (v->a.octet_string_variable), indent + 2 );
        break;

    case GROUPITEM_OBJECT_REF_VARIABLE:
        fprintf(f, ":ObjectRefVar ");
        PrintVariable (f, (v->a.object_ref_variable), indent + 2 );
        break;

    case GROUPITEM_CONTENT_REF_VARIABLE:
        fprintf(f, ":ContentRefVar ");
        PrintVariable (f, (v->a.content_ref_variable), indent + 2 );
        break;

    case GROUPITEM_LINK:
        fprintf(f, ":Link ");
        PrintLinkClass (f, (v->a.link), indent + 2);
        break;

    case GROUPITEM_STREAM:
        fprintf(f, ":Stream ");
        PrintStreamClass (f, (v->a.stream), indent + 2);
        break;

    case GROUPITEM_BITMAP:
        fprintf(f, ":Bitmap ");
        PrintBitmapClass (f, (v->a.bitmap), indent + 2 );
        break;

    case GROUPITEM_LINE_ART:
        fprintf(f, ":LineArt ");
        PrintLineArt (f, (v->a.line_art), indent + 2 );
        break;

    case GROUPITEM_DYNAMIC_LINE_ART:
        fprintf(f, ":DynamicLineArt ");
        PrintLineArt (f, (v->a.dynamic_line_art), indent + 2 );
        break;

    case GROUPITEM_RECTANGLE:
        fprintf(f, ":Rectangle ");
        PrintLineArt (f, (v->a.rectangle), indent + 2);
        break;

    case GROUPITEM_HOTSPOT:
        fprintf(f, ":Hotspot ");
        PrintHotspotClass (f, (v->a.hotspot), indent + 2 );
        break;

    case GROUPITEM_SWITCH_BUTTON:
        fprintf(f, ":SwitchButton ");
        PrintSwitchButtonClass (f, (v->a.switch_button), indent + 2 );
        break;

    case GROUPITEM_PUSH_BUTTON:
        fprintf(f, ":PushButton ");
        PrintPushButtonClass (f, (v->a.push_button), indent + 2 );
        break;

    case GROUPITEM_TEXT:
        fprintf(f, ":Text ");
        PrintText (f, (v->a.text), indent + 2);
        break;

    case GROUPITEM_ENTRY_FIELD:
        fprintf(f, ":EntryField ");
        PrintEntryFieldClass (f, (v->a.entry_field), indent + 2);
        break;

    case GROUPITEM_HYPER_TEXT:
        fprintf(f, ":HyperText ");
        PrintHyperTextClass (f, (v->a.hyper_text), indent + 2 );
        break;

    case GROUPITEM_SLIDER:
        fprintf(f, ":Slider ");
        PrintSliderClass (f, (v->a.slider), indent + 2 );
        break;

    case GROUPITEM_TOKEN_GROUP:
        fprintf(f, ":TokenGroup ");
        PrintTokenGroup (f, (v->a.token_group), indent + 2);
        break;

    case GROUPITEM_LIST_GROUP:
        fprintf(f, ":ListGroup ");
        PrintListGroupClass (f, (v->a.list_group), indent + 2);
        break;

    }

    Indent (f, indent);
    fprintf (f,"}\n");

}  /* PrintGroupItem */

static void
PrintDefaultAttribute PARAMS ((f, v, indent),
                              FILE* f _AND_
                              DefaultAttribute *v _AND_
                              unsigned short int indent)
{
    Indent(f, indent);
    switch (v->choiceId)
    {
    case DEFAULTATTRIBUTE_CHARACTER_SET:
        fprintf (f,":CharacterSet ");
        _PrintAsnInt (f, (&v->a.character_set), 0);
        break;

    case DEFAULTATTRIBUTE_BACKGROUND_COLOUR:
        fprintf (f,":BackgroundColour ");
        PrintColour (f, (v->a.background_colour), 0);
        break;

    case DEFAULTATTRIBUTE_TEXT_CONTENT_HOOK:
        fprintf (f,":TextCHook ");
        _PrintAsnInt (f, (&v->a.text_content_hook), 0);
        break;

    case DEFAULTATTRIBUTE_TEXT_COLOUR:
        fprintf (f,":TextColour ");
        PrintColour (f, (v->a.text_colour), 0);
        break;

    case DEFAULTATTRIBUTE_FONT:
        fprintf (f,":Font ");
        PrintFontBody (f, (v->a.font), 0);
        break;

    case DEFAULTATTRIBUTE_FONT_ATTRIBUTES:
        fprintf (f,":FontAttributes ");
        PrintQPrintableOctetString (f, (v->a.font_attributes));
        break;

    case DEFAULTATTRIBUTE_INTERCHANGED_PROGRAM_CONTENT_HOOK:
        fprintf (f,":InterchgPrgCHook ");
        _PrintAsnInt (f, (&v->a.interchanged_program_content_hook), 0);
        break;

    case DEFAULTATTRIBUTE_STREAM_CONTENT_HOOK:
        fprintf (f,":StreamCHook ");
        _PrintAsnInt (f, (&v->a.stream_content_hook), 0);
        break;

    case DEFAULTATTRIBUTE_BITMAP_CONTENT_HOOK:
        fprintf (f,":BitmapCHook ");
        _PrintAsnInt (f, (&v->a.bitmap_content_hook), 0);
        break;

    case DEFAULTATTRIBUTE_LINE_ART_CONTENT_HOOK:
        fprintf (f,":LineArtCHook ");
        _PrintAsnInt (f, (&v->a.line_art_content_hook), 0);
        break;

    case DEFAULTATTRIBUTE_BUTTON_REF_COLOUR:
        fprintf (f,":ButtonRefColour ");
        PrintColour (f, (v->a.button_ref_colour), 0);
        break;

    case DEFAULTATTRIBUTE_HIGHLIGHT_REF_COLOUR:
        fprintf (f,":HighlightRefColour ");
        PrintColour (f, (v->a.highlight_ref_colour), 0);
        break;

    case DEFAULTATTRIBUTE_SLIDER_REF_COLOUR:
        fprintf (f,":SliderRefColour ");
        PrintColour (f, (v->a.slider_ref_colour), 0);
        break;

    }
    fprintf(f, "\n");
}  /* PrintDefaultAttribute */

static void
PrintApplicationClassSeqOf PARAMS ((f, v, indent),
FILE* f _AND_
ApplicationClassSeqOf *v _AND_
unsigned short int indent)
{
    DefaultAttribute *tmp;
    if (v == NULL)
        return;
    FOR_EACH_LIST_ELMT (tmp, v)
    {
        PrintDefaultAttribute (f, tmp, indent);
    }
}  /* PrintApplicationClassSeqOf */


static void
PrintApplicationClass PARAMS ((f, v, indent),
FILE* f _AND_
ApplicationClass *v _AND_
unsigned short int indent)
{
    if (v == NULL)
        return;

    Indent (f, indent);
    fprintf (f,"{ :Application ");
    PrintRootClass (f, (v->rootClass));
    fprintf (f,"\n");

    if (NOT_NULL ((v->standard_identifier)))
    {
    Indent (f, indent + 2);
    fprintf (f,":StdID ");
    PrintStandardIdentifier (f, (v->standard_identifier), 0);
    fprintf (f,"\n");
    }
    if (NOT_NULL ((v->standard_version)))
    {
    Indent (f, indent + 2);
    fprintf (f,":StdVersion ");
    _PrintAsnInt (f, (v->standard_version), 0);
    fprintf (f,"\n");
    }
    if (ASNOCTS_PRESENT ((&v->object_information)))
    {
    Indent (f, indent + 2);
    fprintf (f,":ObjectInfo ");
    PrintQPrintableOctetString (f, (&v->object_information));
    fprintf (f,"\n");
    }
    if (NOT_NULL ((v->on_start_up)))
    {
    Indent (f, indent + 2);
    fprintf (f,":OnStartUp ");
    PrintActionClass (f, (v->on_start_up), indent + 2);
    }
    if (NOT_NULL ((v->on_close_down)))
    {
    Indent (f, indent + 2);
    fprintf (f,":OnCloseDown ");
    PrintActionClass (f, (v->on_close_down), indent + 2);
    }
    if (NOT_NULL ((v->original_group_cache_priority)))
    {
    Indent (f, indent + 2);
    fprintf (f,":OrigGCPriority ");
    _PrintAsnInt (f, (v->original_group_cache_priority), 0);
    fprintf (f,"\n");
    }
    if (NOT_NULL ((v->items)))
    {
        GroupItem *tmp;
        Indent (f, indent + 2);
        fprintf (f,":Items (\n");
        FOR_EACH_LIST_ELMT (tmp, v->items)
            PrintGroupItem (f, tmp, indent + 4);
        Indent (f, indent + 2);
        fprintf (f,")\n");
    }

    if (NOT_NULL ((v->on_spawn_close_down)))
    {
    Indent (f, indent + 2);
    fprintf (f,":OnSpawnCloseDown ");
    PrintActionClass (f, (v->on_spawn_close_down), indent + 2);
    }
    if (NOT_NULL ((v->on_restart)))
    {
    Indent (f, indent + 2);
    fprintf (f,":OnRestart ");
    PrintActionClass (f, (v->on_restart), indent + 2);
    }
    if (NOT_NULL ((v->default_attributes)))
    {
    PrintApplicationClassSeqOf (f, (v->default_attributes), indent + 2);
    }
    if (NOT_NULL ((v->original_desktop_colour)))
    {
    Indent (f, indent + 2);
    fprintf (f,":OrigDesktopColour ");
    PrintColour (f, (v->original_desktop_colour), indent + 2);
    fprintf (f,"\n");
    }
    Indent (f, indent);
    fprintf (f,"}\n");
}  /* PrintApplicationClass */

static void
PrintSceneClass PARAMS ((f, v, indent),
FILE* f _AND_
SceneClass *v _AND_
unsigned short int indent)
{
    if (v == NULL)
        return;

    Indent (f, indent);
    fprintf(f, "{ :Scene ");
    PrintRootClass (f, (v->rootClass));
    fprintf (f, "\n");
    
    if (NOT_NULL ((v->standard_identifier)))
    {
    Indent (f, indent + 2);
    fprintf (f,":StdID ");
    PrintStandardIdentifier (f, (v->standard_identifier), 0);
    fprintf (f, "\n");
    }
    if (NOT_NULL ((v->standard_version)))
    {
    Indent (f, indent + 2);
    fprintf (f,":StdVersion ");
    _PrintAsnInt (f, (v->standard_version), 0);
    fprintf (f, "\n");
    }
    if (ASNOCTS_PRESENT ((&v->object_information)))
    {
    Indent (f, indent + 2);
    fprintf (f,":ObjectInfo ");
    PrintQPrintableOctetString (f, (&v->object_information));
    fprintf (f, "\n");
    }
    if (NOT_NULL ((v->on_start_up)))
    {
    Indent (f, indent + 2);
    fprintf (f,":OnStartUp ");
    PrintActionClass (f, (v->on_start_up), indent + 2);
    fprintf (f, "\n");
    }
    if (NOT_NULL ((v->on_close_down)))
    {
    Indent (f, indent + 2);
    fprintf (f,":OnCloseDown ");
    PrintActionClass (f, (v->on_close_down), indent + 2);
    fprintf (f, "\n");
    }
    if (NOT_NULL ((v->original_group_cache_priority)))
    {
    Indent (f, indent + 2);
    fprintf (f,":OrigGCPriority ");
    _PrintAsnInt (f, (v->original_group_cache_priority), 0);
    fprintf (f, "\n");
    }
    if (NOT_NULL ((v->items)))
    {
        GroupItem *tmp;
        Indent (f, indent + 2);
        fprintf (f,":Items (\n");
        FOR_EACH_LIST_ELMT (tmp, v->items)
            PrintGroupItem (f, tmp, indent + 4);
        Indent (f, indent + 2);
        fprintf (f,")\n");
    }
    Indent (f, indent + 2);
    fprintf (f,":InputEventReg ");
    _PrintAsnInt (f, (&v->input_event_register), 0);
    fprintf (f, "\n");
    Indent (f, indent + 2);
    fprintf (f,":SceneCS ");
    PrintSceneCoordinateSystem (f, (v->scene_coordinate_system), 0);
    fprintf (f, "\n");
    if (NOT_NULL ((v->aspect_ratio)))
    {
        Indent (f, indent + 2);
        fprintf (f,":AspectRatio ");
        PrintAspectRatio (f, (v->aspect_ratio), 0);
        fprintf (f, "\n");
    }
    if (NOT_NULL ((v->moving_cursor)))
    {
        Indent (f, indent + 2);
        fprintf (f,":MovingCursor ");
        PrintAsnBool (f, (v->moving_cursor), 0);
        fprintf (f, "\n");
    }
    if (NOT_NULL ((v->next_scenes)))
    {
        Indent (f, indent + 2);
        fprintf (f,":NextScenes (\n");
        PrintSceneClassSeqOf (f, (v->next_scenes), indent + 2);
        Indent (f, indent + 2);
        fprintf(f, ")\n");
    }
    Indent (f, indent);
    fprintf (f,"}\n");
}  /* PrintSceneClass */

void
PrintInterchangedObject PARAMS ((f, v, indent),
FILE* f _AND_
InterchangedObject *v _AND_
unsigned short int indent)
{
    switch (v->choiceId)
    {
      case INTERCHANGEDOBJECT_APPLICATION:
    PrintApplicationClass (f, (v->a.application), indent);
          break;

      case INTERCHANGEDOBJECT_SCENE:
    PrintSceneClass (f, (v->a.scene), indent);
          break;

    }
}  /* PrintInterchangedObject */


/*
 * Local variables:
 * mode: c
 * compile-command: "make -C ../"
 *  c-indent-level: 4
 *  c-basic-offset: 4
 *  tab-width: 4
 * End:
 */
